I am new to coredata, this is the 1st time i am using so please bear me as i am expalining. i have 2 Entites named userinfo and usergroups, and they both are related in one to many relationship, Now usergroups(relationshipped name ) field wiil be created in userinfo. And Userinfo has also to many relationship to Usercontacts
Userinfo contains dateofbirth;email;firstname;lastname;password;salutation;userinfoId;username(user contact number);zipcode; usergroups;usercontacts;
Usercontacts contains contactdescription;name;phone(conatct list of users);usercontacts_id;userinfo;
Usergroups containsgroupname;mobile_contacts;mobile_number;usergroups_id;userinfo_group;
I am able to get usergroups object for a particular username(which is unique in userinfo entity), For a particular mobile_contacts(in usergoups Entity) can i get the related name from the Userconatcts Entity.
I was trying like this
NSString *usermobileNumber = [[NSUserDefaults standardUserDefaults] valueForKey:@"UserNumber"];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Userinfo" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSPredicate *datapredicate = [NSPredicate predicateWithFormat:@"username == %@",usermobileNumber];
[fetchRequest setPredicate:datapredicate];
[context executeFetchRequest:fetchRequest onSuccess:^(NSArray *results){
NSLog(@"results %@",[[results valueForKey:@"usergroups"] objectAtIndex:0]);
for (NSString *order in results) {
for (Usergroups *unit in [order usergroups]) {
NSLog(@"%@", unit);
}
}
[fetchRequest release];
}onFailure:^(NSError *error){
NSLog(@"error %@",error);
}];
Any kind of suggestions or help would make me move my work Thanks in Advance