@segiddins टिप्पणी के आधार पर, मैं NSFileManager का उपयोग करके ऐप समूह पुराने डेटाबेस चलती के साथ जाने का फैसला किया:
let fileManager = NSFileManager.defaultManager()
//Cache original realm path (documents directory)
let originalDefaultRealmPath = RLMRealm.defaultRealmPath()
//Generate new realm path based on app group
let appGroupURL: NSURL = fileManager.containerURLForSecurityApplicationGroupIdentifier("group.AppGroup")!
let realmPath = appGroupURL.path!.stringByAppendingPathComponent("default.realm")
//Moves the realm to the new location if it hasn't been done previously
if (fileManager.fileExistsAtPath(originalDefaultRealmPath) && !fileManager.fileExistsAtPath(realmPath)) {
var error: NSError?
fileManager.moveItemAtPath(originalDefaultRealmPath, toPath: realmPath, error: &error)
if (error != nil) {
println(error)
}
}
//Set the realm path to the new directory
RLMRealm.setDefaultRealmPath(realmPath)
क्या कोई कारण है कि आप NSFileManager का उपयोग करके फ़ाइल को स्थानांतरित नहीं कर सकते हैं? – segiddins
एप्पल से परहेज फ़ाइल समन्वय एपीआई पता चलता है, के रूप में डेटा दूषित कर सकते हैं: https://developer.apple.com/library/ios/technotes/tn2408/_index.html – Whoa
के बाद से अपने ऐप्लिकेशन इसे स्थानांतरित करने में सक्षम हो जाएगा, और आप कर सकते हैं इसलिए atomically है, तो आप ठीक हो जाओगे – segiddins