【发布时间】:2015-12-30 06:33:31
【问题描述】:
我在使用 predicateWithFormat 方法创建 NSPredicate 类型对象时遇到问题。
AppDelegate *appdelegateObj = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.managedObjectContext = [appdelegateObj managedObjectContext];
NSString *emailWithBackslashedAtTheRate = [email stringByReplacingOccurrencesOfString:@"@" withString:@"\\@"];
NSFetchRequest *fetchRequestObj = [NSFetchRequest fetchRequestWithEntityName:@"Usertable"];
NSMutableArray *dataList;
**NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"email CONTAINS[c] %@",emailWithBackslashedAtTheRate]];**
[fetchRequestObj setPredicate:predicate];
@synchronized(delegate.persistentStoreCoordinator) {
NSError *error = nil;
NSMutableArray *filteredUser = (NSMutableArray *)[self.managedObjectContext executeFetchRequest:fetchRequestObj error:&error];
}
谁能解释一下,是什么问题?
【问题讨论】:
-
通过调用
executeFetchRequest返回的error是什么? -
emailWithBackslashedAtTheRate 的格式是什么,您的实体中的 email 属性名称是什么?
-
你能记录下是什么问题吗?
-
无法解析格式字符串“(email=iostest1@gmail.com)”
标签: ios core-data nspredicate nsfetchrequest predicatewithformat