我有一个iPad应用程序,它使用MagicalRecord管理我的CoreData商店。当我对记录进行更新时,除了正在更新的记录外,我还会得到一个空记录。
更新:--这是有关实体的图像:
以及ClientInfo:
这是空记录的图像:
这是创建更新的代码:
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,并得到了相同的结果。我害怕的是我的一个用户在他们的设备上没有空间了。有什么想法吗?
发布于 2014-01-22 18:50:58
更有可能的是,您在相同的上下文中创建一个空对象。它显示在数据库中,因为当您调用save时,它就在数据库中。查找对mr_createEntity或mr_createInContext的调用:并查看实际创建的内容。您还可以在代码中的该保存点上中断,并在lldb中运行以下命令:
po [context insertedObjects]
查看结果集。如果其中一个对象不是您所期望的,那么您很可能会预先在某个地方创建一个空白对象。
https://stackoverflow.com/questions/21290577
复制相似问题