码迷,mamicode.com
首页 > 其他好文 > 详细

coredata01

时间:2015-07-23 23:35:07      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

// 添加一条通告
+ (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

coredata01

标签:

原文地址:http://www.cnblogs.com/javastart/p/4672007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!