MagicalRecord(CoreData)今日推广(iOS8)……他们会玩吗?

MagicalRecord(CoreData)今日推广(iOS8)……他们会玩吗?,第1张

概述希望你能帮忙.我正在为我的应用添加今日支持,它使用MagicalRecord https://github.com/magicalpanda/MagicalRecord管理我的所有CoreData内容. 我正在试图理解如何将我的数据显示在今天的扩展中. 我已经启用了http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-bet 希望你能帮忙.我正在为我的应用添加今日支持,它使用MagicalRecord https://github.com/magicalpanda/MagicalRecord管理我的所有CoreData内容.

我正在试图理解如何将我的数据显示在今天的扩展中.

我已经启用了http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios-8中概述的应用程序组,但是我正在阅读的所有文档和StackOverflow帖子都与直接使用CoreData有关. MagicalRecord为你做了很多艰苦的工作,这就是我使用它的原因,因为我在这个项目的开头就是全新的.所以像:

Where you initialise your Core Data stack,you’ll be adding a store to
your persistentStoreCoordinator a little something like this:

[persistentStoreCoordinatoraddPersistentStoreWithType:NSsqliteStoreType configuration:nilURL:storeURL options:options error:&error]

It’s simply a matter of changing your prevIoUs value for storeURL
(usually somewhere in NSdocumentDirectory) to a location contained in
your shared App Group folder. You do this using

containerURLForSecurityApplicationGroupIDentifIEr: NSURL *directory =[[NSfileManager defaultManager]containerURLForSecurityApplicationGroupIDentifIEr:@"group.YourGroupname"];NSURL *storeURL = [directory URLByAppendingPathComponent:@"YourAppname.sqlite"];

……我不明白如何/在哪里实施.

我想象我必须像我在appDelegate中那样在我的扩展中设置MagicalRecord堆栈,但当然它失败了.

真的希望有人可能处于类似的情况,并能够阐明如何推进这个问题.

你需要我发布的任何代码让我知道.

提前致谢

解决方法 不确定这是否适用于以前版本的MagicalRecord,但从2.2开始,您可以将最终的URL作为商店名称传递:
NSfileManager *fileManager = [[NSfileManager alloc] init];NSURL *directory = [fileManager containerURLForSecurityApplicationGroupIDentifIEr:@"group.yellow"];NSURL *pathToStore = [directory URLByAppendingPathComponent:kMagicalRecordDefaultStorefilename];[MagicalRecord setupCoreDataStackWithautoMigratingsqliteStorenamed:(ID)pathToStore];
总结

以上是内存溢出为你收集整理的MagicalRecord(CoreData)今日推广(iOS8)……他们会玩吗?全部内容,希望文章能够帮你解决MagicalRecord(CoreData)今日推广(iOS8)……他们会玩吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1105495.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存