-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ和需要注意的地方
Fidetro edited this page Oct 20, 2017
·
1 revision
- 需要注意的地方 用新插入的对象,再去update,这个做法是错误的❌
FFStore *store = [[FFStore alloc]init];
[store insertObject];
store.name = "711";
[store updateObject];//这个做法是错误的
正确的做法✅
FFStore *store = [[FFStore alloc]init];
[store insertObject];
FFStore *dbStore = [[FFStore selectFromClassAllObject]lastObject];
dbStore.name = "711";
[dbStore updateObject];//这个做法是错误的
这是因为刚刚插入的对象,sqlite不会返回自增的primaryID
,所以store在插入结束后,primaryID
依然为空,- (BOOL)updateObject;
的方法是基于primaryID
更新,所以更新是无法成功的。