Cannot add object to an NSMutableArray array

后端 未结 2 546
旧巷少年郎
旧巷少年郎 2020-12-21 05:09
@interface SimataDetailViewController () 

@property Simata *simata;

@property (nonatomic, copy) NSMutableArray *simataList;

@end

@implementation SimataDetailView         


        
相关标签:
2条回答
  • 2020-12-21 05:22

    Are you sure you have created an instance of the array before you use it?

    self.simataList =[NSMutableArray array];
    

    It could also be your self.simata being nil...

    EDIT

    You could create the array instance in the default init method:

    -(id)init
    {
        self = [super init];
        if(self)
        {
            //do your object initialization here
            self.simataList =[NSMutableArray array];
        }
        return self;
    }
    
    0 讨论(0)
  • 2020-12-21 05:26

    Most likely self.simataList is nil. Try NSLogging self.simataList itself, rather than its count.

    0 讨论(0)
提交回复
热议问题