- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个应用程序在 AppDelegate 中使用 Core Data 和标准的 Apple Core Data 堆栈。我修改了堆栈,以便使用 CloudKit 增强核心数据。所有数据都很好地在所有设备上同步。到目前为止一切顺利。
我想在我的应用程序中添加 Today Extension,但我不知道如何访问数据。我一直在阅读 AppGroup 概念,但我也读到我不应该/不能使用它来访问 Today Extension 中的数据。所以我想我应该使用 CloudKit,因为我了解到 NSManagedObjects 在上传到 iCloud 时会转换为 CKRecords。
我如何通过 iCloud 访问由 Core Data 使用 CloudKit 增强功能存储的数据?这些数据究竟存储在 iCloud 中的什么位置?
虽然所有数据都很好地同步,但当我检查 iCloud 仪表板时,似乎不存在任何数据。我阅读的所有 SO 文章似乎只解决了我的部分问题。
这是我在我的应用程序中使用的修改后的核心数据堆栈:
// MARK: - Core Data stack
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
let modelURL = NSBundle.mainBundle().URLForResource("AppName", withExtension: "momd")!
return NSManagedObjectModel(contentsOfURL: modelURL)!
}()
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
// The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
// Create the coordinator and store
var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
let documentDirectory = NSFileManager.defaultManager().URLsForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomains: NSSearchPathDomainMask.UserDomainMask).last as! NSURL
let storeUrl = documentDirectory.URLByAppendingPathComponent("AppName.sqlite")
var error: NSError? = nil
var failureReason = "There was an error creating or loading the application's saved data."
let storeOptions = [NSPersistentStoreUbiquitousContentNameKey:"ItemsCloudStore"]
let url = storeUrl
if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: storeOptions, error: &error) == nil {
coordinator = nil
// Report any error we got.
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
dict[NSLocalizedFailureReasonErrorKey] = failureReason
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
// Replace this with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("Unresolved error \(error), \(error!.userInfo)")
abort()
}
return coordinator
}()
lazy var managedObjectContext: NSManagedObjectContext? = {
// Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.MainQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
// MARK: - Core Data Saving support
func saveContext () {
if let moc = self.managedObjectContext {
var error: NSError? = nil
if (moc.hasChanges && !moc.save(&error)) {
println("Unresolved error \(error), \(error!.userInfo)")
abort()
} else {
println("Context was updated")
}
}
}
最佳答案
经过一些研究,这似乎是 Apple 尚未解决的问题。 Core Data 和 iCloud 不能与 Extensions 一起使用。看看这篇文章:
https://devforums.apple.com/message/1050891#1050891
有点无赖。希望他们至少在 iOS9 中修复它。
关于ios - 如何通过 Today Extension (iOS 8) 访问 Core Data/CloudKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32039465/
我有一个问题,我想通过其他程序打开 chrome://extensions/页面,例如 cmd.exe 或其他程序。 我们知道,如果我们用chrome.exe打开一个网站,我们可以在cmd.exe中执
当您编写manifest.json 文件时,您必须为内容脚本指定匹配。 http 和 https 工作正常,但如果我尝试包含 chrome://*/* 或其任何变体,我会得到一个我尝试对我的匹配使用无
我真的很困惑我想制作一个可以扩展用户的Google日历的Chrome扩展程序,我应该在Google API下注册哪种程序? 它是Web App吗?但是我不打算让服务器托管任何东西,因为Chrome扩展
我想在带有chrome-extension://URL的iframe上运行内容脚本。我在我的manifest.json文件中添加了一行代码,该行是从http://code.google.com/chr
目前,我正在使用记事本和 chrome 控制台的组合对我的 google-chrome-extensions 进行编码。我 100% 确信有更好的方法来对这些扩展进行编程。人们使用什么环境? 最佳答案
在编写 manifest.json 文件时,必须指定 matches用于您的内容脚本。 http和 https工作正常,但如果我尝试包含 chrome://*/*或它的任何变体,我收到一个错误,提示我
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 7 年前。 Improve
在发布更新后,我正在尝试为我的 Chrome 扩展程序的用户创造流畅的体验。 我在更新应用程序时重新注入(inject)了我的内容脚本,即使用户继续在扩展更新后未刷新的页面上使用我的扩展,我的功能仍然
将扩展程序从 Chrome 移植到 FF 遵循本教程(在 Chrome 中运行良好):http://www.codingscripts.com/check-whether-user-has-a-chr
我正在将 google-chrome 扩展改编成 firefox。 这个扩展相当简单,它只是重新加载当前浏览器窗口并在其中放置一个特定的字符串(它用于在 Odoo 上激活调试状态)。 但是,当我在 m
我正在尝试在普通 HTML 页面(非扩展)中链接到 chrome://extensions。但是单击链接不会执行任何操作: chrome://extensions 右键单击并在新选项卡中打开只会打开
为 String 编写扩展名很容易,但问题是它总是显示为 "MyString".ExtensionMethod() 如果这样写: public static class Extensions{
如题。我正在运行 Joomla 2.5。 “扩展”下拉菜单中唯一可见的项目是: 模块经理 插件管理器 模板管理器 语言经理 编辑:我这样做是为了安装模板,按照此页面上的说明:http://docs.j
基本上我希望文件名以扩展名列表中的扩展名结尾。这是我在 python 中的代码。我已经将一些示例文件名作为列表,如下所示: extensions = ['.mp3','.m4a','.wma'] fi
在 background.html : chrome.tabs.query({active:true, currentWindow:true},function(tabs){ chrome.tab
我有一个可能被用户禁用的 chrome 扩展。在这种情况下,我想创建一个指向 chrome://extensions 菜单的链接。它会是这样的 Chrome extensions 这是不允许的:不允许
我查看了 Google 文档,但不知道如何更改其类型。 这是我加载时遇到的错误。 尝试安装此扩展时出现警告:“browser_action”仅允许用于扩展程序,这是一个旧版打包应用程序。 这是我的ma
我有一个正在构建的 chrome 扩展,它使用 OAuth 访问许多 API。我没有将我的消费者 secret 存储在扩展程序中,而是重定向到获取 token 的服务器,然后重定向回我的扩展程序中的页
我有一个正在构建的 chrome 扩展,它使用 OAuth 访问许多 API。我没有将我的消费者 secret 存储在扩展程序中,而是重定向到获取 token 的服务器,然后重定向回我的扩展程序中的页
这个问题已经有答案了: Why would a developer place a forward slash at the start of each relative path? (4 个回答)
我是一名优秀的程序员,十分优秀!