首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用CoreData更新MagicalRecord记录会创建额外的空记录

使用CoreData更新MagicalRecord记录会创建额外的空记录
EN

Stack Overflow用户
提问于 2014-01-22 18:06:01
回答 1查看 467关注 0票数 0

我有一个iPad应用程序,它使用MagicalRecord管理我的CoreData商店。当我对记录进行更新时,除了正在更新的记录外,我还会得到一个空记录。

更新:--这是有关实体的图像:

以及ClientInfo:

这是空记录的图像:

这是创建更新的代码:

代码语言:javascript
运行
复制
if(updateFlag == NO)  //  record has been pre-loaded to enable update
    ai.aApptKey = selectedClientKey;  //  new key

ai.aStartTime = selectedStartDate;
ai.aEndTime= selectedEndDate;
ai.aServiceTech = boStaff.text;
ai.aServices = soServices.text;
ai.aNotes = soNotes.text;
ai.aImage = UIImageJPEGRepresentation(oApptImage.image, 1.0);
ai.aPosX = [NSNumber numberWithFloat: x];  //  indicates column start
ai.aPosY = [NSNumber numberWithFloat: fOffsetFromShopOpens + (iNumberOfSegments*2)];  //  appointment start slot in points.y
ai.aPosW = [NSNumber numberWithFloat: 214.0];
ai.aPosH = [NSNumber numberWithFloat: (intEndTime - intStartTime)];  //  appointment height in grid units (25 per each 15 minutes)

//    [localContext MR_saveToPersistentStoreWithCompletion:nil];  //  store it...
[localContext MR_saveToPersistentStoreAndWait];  //  store it...

我正在使用MR_saveToPersistentStoreWithCompletion,并决定改为MR_saveToPersistentStoreAndWait,并得到了相同的结果。我害怕的是我的一个用户在他们的设备上没有空间了。有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-22 18:50:58

更有可能的是,您在相同的上下文中创建一个空对象。它显示在数据库中,因为当您调用save时,它就在数据库中。查找对mr_createEntity或mr_createInContext的调用:并查看实际创建的内容。您还可以在代码中的该保存点上中断,并在lldb中运行以下命令:

代码语言:javascript
运行
复制
po [context insertedObjects]

查看结果集。如果其中一个对象不是您所期望的,那么您很可能会预先在某个地方创建一个空白对象。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21290577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档