1
我有一個今日擴展的應用程序。在MainApp的AppDelegate.swift
:在iOS今日擴展中使用領域
let realmContext = try! Realm(fileURL: NSFileManager
.defaultManager()
.containerURLForSecurityApplicationGroupIdentifier("group.this.is.test")!
.URLByAppendingPathComponent("db.realm"))
在我todayExtension的viewDidLoad:
let realmContext = try! Realm(fileURL: NSFileManager
.defaultManager()
.containerURLForSecurityApplicationGroupIdentifier("group.this.is.test")!
.URLByAppendingPathComponent("db.realm"))
那些完全相同。但是,它在MainApp中起作用,並且當我想在今天的擴展中使用它時,我在Notification Center中獲得Unable to load
。 問題是領域,因爲當我從代碼中刪除let realmContext = ...
,今天擴展沒有問題。 有什麼不對?
確保App Group在您今天的擴展中正確配置。你還可以提供你在Xcode控制檯中看到的任何錯誤消息嗎? – Dmitry