ios - NSFetchRequest two entities and put them in NSMutableArray -
i trying fill tableview nsfetchrequest 2 entities using code:
@property (strong) nsmutablearray *forms; nsmanagedobjectcontext *managedobjectcontext = [self managedobjectcontext]; nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] initwithentityname:@"names"]; nsfetchrequest *fetchrequest2 = [[nsfetchrequest alloc] initwithentityname:@"forms"]; self.forms = [[managedobjectcontext executefetchrequest:fetchrequest error:nil] mutablecopy]; self.forms = [[managedobjectcontext executefetchrequest:fetchrequest2 error:nil] mutablecopy]; [self.tableview reloaddata]; now know right self.forms overwritten second fetch, dont know how accomplish putting in self.forms array
try this:
self.forms = [[managedobjectcontext executefetchrequest:fetchrequest error:nil] mutablecopy]; [self.forms addobjectsfromarray:[[managedobjectcontext executefetchrequest:fetchrequest2 error:nil] mutablecopy]];
Comments
Post a Comment