Trouble with Core Data
- Get link
- X
- Other Apps
ok trying grab nsmutable set. yes have previous post on different. have player entity , team entity. set 1 many relationship... on different view controller added players team. trying teams players show on table view... fetching information follows.
then on cell row @ index path setting player object fetched results followscode:- (nsfetchedresultscontroller *)fetchedresultscontroller { if (_fetchedresultscontroller != nil) { return _fetchedresultscontroller; } nsstring *entityname = @"team"; nslog(@"setting fetched results controller entity named %@", entityname); // 2 - request entity nsfetchrequest *request = [nsfetchrequest fetchrequestwithentityname:entityname]; appdelegate *delegate = [[uiapplication sharedapplication] delegate]; _managedobjectcontext = delegate.managedobjectcontext; // 4 - sort request.sortdescriptors = [nsarray arraywithobject:[nssortdescriptor sortdescriptorwithkey:@"players" ascending:no selector:@selector(localizedcaseinsensitivecompare:)]]; // 5 - fetch self.fetchedresultscontroller = [[nsfetchedresultscontroller alloc] initwithfetchrequest:request managedobjectcontext:self.managedobjectcontext sectionnamekeypath:nil cachename:nil]; _fetchedresultscontroller.delegate = self; return _fetchedresultscontroller; }
code:player *p = [_fetchedresultscontroller objectatindexpath:indexpath]; then, setting title of cell so.i getting errorcode:cell.textlabel = p.firstname;
i wondering doing wrong???code:reason: 'to-many key not allowed
as you've got shown fetchrequest returning teams not players.
fetchedresultscontroller ask entity interested in. if tableview showing list of "players" set fetchedresultscontroller entity 'players' not 'team'.
can use other settings of fetch request filter down results interested in. find it's easier build each view piece meal. 1 bit working refine, refine, refine.
refinement @ predicate. have @ nspredicate. fetched results use predicate see if should include entities in results.so in case players team equal team focusing on this.
with fetched results sorting purely ordering of objects returned. should using players name or number sort players.code:nspredicate *predicate = [nspredicate predicatewithformat:@"team '%@'", team];
if had fetched results set let know if new player added team, delegate methods called prompt tableview update.
btw: have keep in same thread. helps people understand what's been discussed.
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
- Get link
- X
- Other Apps
Comments
Post a Comment