के साथ कोर डेटा NSFetchRequest मेरे पास एक fetch अनुरोध है कि परिणाम से दो खंडों के साथ एक तालिकादृश्य में शोल परिणाम।समूह डेटा
मेरे मॉडल:
@interface Player : NSManagedObject
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * isFacebookFriend;
इस मॉडल पर अनुरोध लाने लोगों की है कि isFacebookFriend हैं के साथ एक अनुभाग में परिणाम चाहिए == हाँ एक खंड में, और isFacebookFriend == कोई दूसरे खंड में।
मैं
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
HBAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Player" inManagedObjectContext:appDelegate.managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *nameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
[fetchRequest setSortDescriptors:@[nameDescriptor]];
[fetchRequest setResultType:NSDictionaryResultType];
[fetchRequest setPropertiesToGroupBy:@[@"isFacebookFriend"]];
_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:appDelegate.managedObjectContext sectionNameKeyPath:nil cacheName:@"playerCache"];
NSError *error;
[_fetchedResultsController performFetch:&error];
साथ करने की कोशिश की लेकिन वह ऐसा नहीं किया। यह त्रुटि थी:
2013-06-12 12:27:28.364 TwentyQuestions[25015:c07] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0xb676aa0>.
2013-06-12 12:27:31.119 TwentyQuestions[25015:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'SELECT clauses in queries with GROUP BY components can only contain properties named in the GROUP BY or aggregate functions ((<NSAttributeDescription: 0xc382320>), name hasRegisteredForGame, isOptional 1, isTransient 0, entity Player, renamingIdentifier hasRegisteredForGame, validation predicates (
), warnings (
), versionHashModifier (null)
userInfo {
}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null) is not in the GROUP BY)'
शायद अपना पूरा प्राप्त अनुरोध कोड दिखाएं? –
इसे जोड़ा गया। बस कोर डेटा से मानक लाने – hakonbogen