本文介绍了禁用MagicalRecord错误消息和警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我刚刚开始使用MagicalRecord,这可能是一个愚蠢的问题,但它真的困扰我... 我使用MagicalRecord与sqlite,当我启动MagicalRecord,我使用 [MagicalRecord setupCoreDataStackWithStoreNamed:@OrderSystem.sqlite]; 并生成以下消息: 2012-10-16 16:54:48.966 OrderSystem [4135:c07] + NSManagedObjectContext(MagicalRecord)MR_contextWithStoreCoordinator: - >创建:上下文 * MAIN THREAD * > 当我尝试使用下面的代码存储我的实体: [MagicalRecord saveInBackgroundWithBlock:^(NSManagedObjectContext * localContext){ Menu * localMenu = [menu inContext:localContext]; localMenu.name = menu.name; localMenu.menuid = menu.menuid; }]; 我收到以下错误消息: 2012-10-16 17:05:20.118 OrderSystem [4523:4603] + MagicalRecord(ErrorHandling)defaultErrorHandler:错误消息:无法完成操作。 (Cocoa错误133000。) 2012-10-16 17:05:20.118 OrderSystem [4523:4603] + MagicalRecord(ErrorHandling)defaultErrorHandler:Error Domain:NSCocoaErrorDomain 2012-10-16 17:05:20.119 OrderSystem [4523:4603] + MagicalRecord(ErrorHandling)defaultErrorHandler:恢复建议:(null) 2012-10-16 17:05:20.119 OrderSystem [4523:4603] -NSManagedObjectContext(MagicalSaves)MR_saveWithErrorCallback:NO CHANGES IN CONTEXT:Context - NOT SAVING 2012-10-16 17:05:20.120 OrderSystem [4523:c07] -NSManagedObjectContext(MagicalSaves)MR_saveWithErrorCallback: - >保存: * DEFAULT 上下文 MAIN THREAD * 2012-10-16 17:05:20.121 OrderSystem [4523:c07] -NSManagedObjectContext(MagicalRecord)contextWillSave:Context: * DEFAULT 上下文 MAIN THREAD * 即将保存。获取新插入对象的永久ID 2012-10-16 17:05:20.142 OrderSystem [4523:1303] -NSManagedObjectContext(MagicalSaves)MR_saveWithErrorCallback: * Background SAVE * 上下文 2012-10-16 17:05:20.142 OrderSystem [4523:1303] -NSManagedObjectContext(MagicalRecord)contextWillSave:上下文: * Background SAVE * 上下文即将保存。获取新插入的对象的永久ID 当我使用findAll检查我的存储数据实体时,它似乎存储在数据库。如果我完全关闭应用程序,并重新启动应用程序,实体仍然存在(这表明实体已被永久存储,而不只是在内存中)。所以看起来一切都是工作,但任何想法是什么是错误消息?并有什么办法可以把它们关闭?或解决它们?因为它阻塞了我的其他NSLog ... 谢谢解决方案找到它。在之前的Prefix.pch文件中添加 #define MR_ENABLE_ACTIVE_RECORD_LOGGING 0 #importCoreData + MagicalRecord.h I just started using MagicalRecord, and this might be a stupid question, but it's really bothering me...I am using MagicalRecord with sqlite, and when I initiate MagicalRecord, I used [MagicalRecord setupCoreDataStackWithStoreNamed:@"OrderSystem.sqlite"];and it produced the following messages: 2012-10-16 16:54:48.966 OrderSystem[4135:c07] +NSManagedObjectContext(MagicalRecord) MR_contextWithStoreCoordinator: -> Created : Context * MAIN THREAD *When I tried to store my entity with the following code using a background thread:[MagicalRecord saveInBackgroundWithBlock:^(NSManagedObjectContext *localContext){ Menu *localMenu = [menu inContext:localContext]; localMenu.name = menu.name; localMenu.menuid = menu.menuid ;}];And I got the following error messages: 2012-10-16 17:05:20.118 OrderSystem[4523:4603] +MagicalRecord(ErrorHandling) defaultErrorHandler: Error Message: The operation couldn’t be completed. (Cocoa error 133000.) 2012-10-16 17:05:20.118 OrderSystem[4523:4603] +MagicalRecord(ErrorHandling) defaultErrorHandler: Error Domain: NSCocoaErrorDomain 2012-10-16 17:05:20.119 OrderSystem[4523:4603] +MagicalRecord(ErrorHandling) defaultErrorHandler: Recovery Suggestion: (null) 2012-10-16 17:05:20.119 OrderSystem[4523:4603] -NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback: NO CHANGES IN CONTEXT : Context - NOT SAVING 2012-10-16 17:05:20.120 OrderSystem[4523:c07] -NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback: -> Saving : * DEFAULT Context MAIN THREAD * 2012-10-16 17:05:20.121 OrderSystem[4523:c07] -NSManagedObjectContext(MagicalRecord) contextWillSave: Context : * DEFAULT Context MAIN THREAD * is about to save. Obtaining permanent IDs for new 1 inserted objects 2012-10-16 17:05:20.142 OrderSystem[4523:1303] -NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback: -> Saving : * BACKGROUND SAVE * Context 2012-10-16 17:05:20.142 OrderSystem[4523:1303] -NSManagedObjectContext(MagicalRecord) contextWillSave: Context : * BACKGROUND SAVE * Context is about to save. Obtaining permanent IDs for new 1 inserted objectsWhen I check my stored data entity using findAll, it does seem to be stored in the database. And if I close the application completely, and relaunch the application, the entity is still there (which suggest the entity had been stored persistently, and not just in the memory). So it seems like everything is working, but any idea what are those error messages? and is there any way to turn them off? or solve them? because it's blocking my other NSLog...Thank you 解决方案 found it. add #define MR_ENABLE_ACTIVE_RECORD_LOGGING 0 in your Prefix.pch file before #import "CoreData+MagicalRecord.h" 这篇关于禁用MagicalRecord错误消息和警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-18 16:17