iphone - Core Data Fetch Request -
iphone - Core Data Fetch Request -
i have datamodel looks this:
i show list of customers on tableview, when user selects customer, shows list of rooms client - works fine.
the problem getting when seek , show detail view room. when user selects room, shows view values of room. (well should do). have working extent, if have 2 rooms named same ie - "bedroom 1", 2 different customers doesnt show right room data.
here code using:
appdelegate_shared *appdelegate = [[uiapplication sharedapplication] delegate]; nsmanagedobjectcontext *context = [appdelegate managedobjectcontext]; nsentitydescription *entitydesc = [nsentitydescription entityforname:@"rooms" inmanagedobjectcontext:context]; nsfetchrequest *request = [[nsfetchrequest alloc] init]; [request setentity:entitydesc]; nspredicate *pred = [nspredicate predicatewithformat:@"(room = %@)", titlestr]; [request setpredicate:pred]; nsmanagedobject *matches = nil; nserror *error; nsarray *objects = [context executefetchrequest:request error:&error]; if ([objects count] == 0) { nslog(@"no matches"); } else { matches = [objects objectatindex:0]; nslog(@"matches found"); albl.text = [matches valueforkey:@"dima"]; } [request release]; [nsfetchedresultscontroller deletecachewithname:nil]; [self.fetchedresultscontroller.fetchrequest setpredicate:pred];
what want happen, detail view shows details based on client chosen.
any help much appreciated...
thanks
change predicate include client searching for.
imagine sql (assuming have used sql), predicate clause. if room isn't unique, homecoming rooms same name.
what want rooms room == roomname , client == customerid.
iphone objective-c core-data
Comments
Post a Comment