我可以与应用程序组共享iOS领域数据库吗?如果有,怎么样?如果没有,我如何将我的Realm数据库共享给我的其他应用程序?
答案 0 :(得分:7)
要在同一iOS应用程序组中的应用程序之间共享领域,您需要为领域指定一个公共位置:
import Cocoa
class MainWindowController: NSWindowController
{
var secondaryViewController:NSViewController?
override func windowDidLoad()
{
super.windowDidLoad()
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
@IBAction func segmentedControlDidChange(_ sender: NSSegmentedControl)
{
print("Index: \(sender.selectedSegment)")
if sender.selectedSegment == 3 {
if secondaryViewController == nil {
let viewController = storyboard?.instantiateController(withIdentifier: "SecondaryViewController") as! NSViewController
secondaryViewController = viewController
}
self.window?.contentViewController = self.secondaryViewController
}
}
}