【发布时间】:2014-03-22 05:36:01
【问题描述】:
SQL 命令
从 GAMELOCALTEAM 不在“TBC”顺序中的游戏中选择 GAMELOCALTEAM 由 GAMELOCALTEAM 提供
我想在objective c 中编写sql 命令。下面是我的文字代码
NSManagedObjectContext * context = ((AFLAppDelegate *)[[UIApplication sharedApplication] delegate] ).managedObjectContext;
NSFetchRequest* fetch = [NSFetchRequest fetchRequestWithEntityName:@“game”];
NSEntityDescription *entity = [NSEntityDescription entityForName:@“game” inManagedObjectContext:context];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT(gamelocalteam IN 'tbc')"];
[fetch setPredicate:predicate];
NSSortDescriptor *sortDescreptor =[[NSSortDescriptor alloc]initWithKey:@"gamelocalteam" ascending:YES];
[fetch setSortDescriptors:[NSArray arrayWithObject:sortDescreptor]];
NSAttributeDescription* attributeDescription = [entity.attributesByName objectForKey:@"gamelocalteam"];
[fetch setPropertiesToFetch:[NSArray arrayWithObjects:attributeDescription, nil]];
[fetch setPropertiesToGroupBy:[NSArray arrayWithObject:attributeDescription]];
[fetch setResultType:NSDictionaryResultType];
NSError *error = nil;
_team = [context executeFetchRequest:fetch error:&error];
如果此通话应用程序崩溃,谓词格式为@"NOT(gamelocalteam IN 'tbc')。
NOT IN可以吗?
【问题讨论】:
-
@Natarajan 谢谢你的帮助
标签: ios objective-c core-data nspredicate nsfetchrequest