标签:
// 添加一条通告
+ (ClassEvent *)eventWithId:(NSString *)eventId {
ClassEvent *item = nil;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(event_id == %@) and (user == %@)", eventId, [LoginManagerInstance() accountName]];
item = [[CoreDataManager objectsForEntity:ClassEventEntityName matchingPredicate:predicate] lastObject];
return item;
}
+ (ClassEvent *)eventInsertWithId:(NSString *)eventId {
ClassEvent *item = [ClassDataManager eventWithId:eventId];
if(!item) {
item = (ClassEvent *)[CoreDataManager insertNewObjectForEntityForName:ClassEventEntityName];
item.event_id = eventId;
item.user = [LoginManagerInstance() accountName];
}
return item;
}
+ (ClassEvent *)eventWitdhDict:(NSDictionary *)dict {
NSString *eventId = [ClassEvent idWithDict:dict];
ClassEvent *item = [ClassDataManager eventInsertWithId:eventId];
item.isGetByBookmarkList = [NSNumber numberWithBool:NO];
[item updateWithDict:dict];
return item;
}
+ (ClassEvent *)eventWitdhFavourDict:(NSDictionary *)dict {
NSString *eventId = [ClassEvent idWithDict:dict];
ClassEvent *item = [ClassDataManager eventWithId:eventId];
// otherwise create new
if (!item) {
item = (ClassEvent *)[CoreDataManager insertNewObjectForEntityForName:ClassEventEntityName];
item.isGetByBookmarkList = [NSNumber numberWithBool:YES];
}
item.user = [LoginManagerInstance() accountName];
[item updateFavourWithDict:dict];
return item;
}
DrPalmEBaby-815ea47eccac6e395414921b862c9ba118c8ba54
标签:
原文地址:http://www.cnblogs.com/javastart/p/4672007.html