我的类(class)有一个变量。这是自定义模型的数组。我想在方法 1 中填充此变量。但应用程序在此行崩溃:[inboxMessagesArray addObject:entity]
Thread 1: EXC_BAD_ACCESS
在 .m 文件中:
@synthesize inboxMessagesArray;
在 .h 文件中:
@property (nonatomic,retain) NSMutableArray<InboxMessagesResponseEntity *> *inboxMessagesArray;
方法1
for (NSDictionary *responseEntityDictionary in dictionary)
{
InboxMessagesResponseEntity *entity = [[InboxMessagesResponseEntity alloc] initWithDictionary:responseEntityDictionary error:&err];
[inboxMessagesArray addObject:entity];
}
最佳答案
在向数组添加对象之前,您需要初始化数组 inboxMessagesArray
self.inboxMessagesArray = [NSMutableArray new]; // OR [[NSMutableArray alloc] init];
关于ios - 在 objective-c 中填充一组自定义模型崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52294074/