什么可能导致 NSMigrationManager 返回 nil 错误?
我有这样的代码:
NSError *error; // NSMigrationManager hates it if you don't provide an error pointer
BOOL result = [manager migrateStoreFromURL:sStoreURL
type:NSSQLiteStoreType
options:nil
withMappingModel:mappingModel
toDestinationURL:dStoreURL
destinationType:NSBinaryStoreType
destinationOptions:nil
error:&error];
令我惊讶的是,它有时会返回 NO 并将 error
指针保留/设置为 nil。什么会导致这种情况?
I have this code:
NSError *error; // NSMigrationManager hates it if you don't provide an error pointer
BOOL result = [manager migrateStoreFromURL:sStoreURL
type:NSSQLiteStoreType
options:nil
withMappingModel:mappingModel
toDestinationURL:dStoreURL
destinationType:NSBinaryStoreType
destinationOptions:nil
error:&error];
To my surprise, it's sometimes returning NO and leaving/setting the error
pointer to nil. What can cause this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的自定义迁移策略在未设置
error
指针的情况下返回NO
,则会导致这种情况。例如,仔细检查代码以查找可能发生这种情况的任何情况。
This is caused if you have a custom migration policy that returns
NO
without setting theerror
pointer. e.g.Check the code carefully to find any situations where this could occur.