騰訊微信開源的一個數(shù)據(jù)庫 WCDB 官方介紹讀寫效率比FMDB要快好幾倍爽航,api 相對于FMDB 更直白簡潔,效率體驗了一把,的確如此届谈。
NSString *path = [NSHomeDirectory() stringByAppendingString:@"/DB/WC.db"];WCTDatabase *database = [[WCTDatabase alloc] initWithPath:path];BOOL result = [database createTableAndIndexesOfName:@"message"withClass:Message.class];Message *message = [[Message alloc] init];message.mes_id = @"1213";message.title = @"Hello, WCDB!";message.time = [NSDate date];for (NSInteger i = 0; i<100000; i++) {BOOL result1 = [database insertObject:messageinto:@"message"];}
//UPDATE message SET content="Hello, Wechat!";Message *message2 = [[Message alloc] init];message.title = @"Hello, Wechat!";BOOL result3 = [database updateRowsInTable:@"message" onProperty:Message.title withObject:message orderBy:Message.mes_id.order() limit:20];//Retrieve//SELECT * FROM message ORDER BY localIDNSArray *messages = [database getObjectsOfClass:Message.classfromTable:@"message"orderBy:Message.mes_id.order()];NSLog(@"messages:%@",messages);