app crash when we add Unmanaged Object to array of another another unmanaged object.
@interface JOCallDetail : RLMObject
@property (nonatomic, strong) NSString * primaryId;
@property (nonatomic, assign) RLMArray<JOAttachment> *attachmentUrls;
@end
@implementation JOCallDetail
+(NSString *)primaryKey{
return @"primaryId";
}
+(JOCallDetail *)initWithJSONDictionary:(NSDictionary *)dictionary{
NSString *primaryId = dictionary[@"call_id"];
JOCallDetail *cd=[[JOCallDetail alloc]init];
cd.primaryId=primaryId;
for (NSDictionary *at in dictionary[@"attachment_urls"]) {
NSString *url=at[@"url"];
if (!url.length) {
url=at[@"media_url"];
}
JOAttachment *a = [[JOAttachment alloc]init];
a.attachmentId = at[@"attachment_id"];
a.mediaUrl = url?url:@"";
a.dataFrom = 0;
a.mediaType = @"image";
a.referenceId = primaryId;
[cd.attachmentUrls addObject:a];
}
return cd;
}
@end
My app crash when i try to add call detail from my json response, here is my code
RLMRealm *realm = [RLMRealm defaultRealm];
[realm transactionWithBlock:^{
NSMutableArray *allPendingCalls = [jsonDict[@"current_calls"] mutableCopy];
for (NSDictionary *pendingCall in allPendingCalls) {
JOCallDetail *cd = [JOCallDetail initWithJSONDictionary:pendingCall];
[realm addOrUpdateObject:cd];
}
} error:nil];
Error I got
Terminating app due to uncaught exception 'RLMException', reason: 'Invalid value (NSPoint: {0, 0}) for 'JOAttachment' array property 'JOCallDetail.attachmentUrls': value is not enumerable.'