на основе @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
Apple предлагает избегать API координации файлов, поскольку данные могут быть повреждены: https://developer.apple.com/library/ios/technotes/tn2408/_index.html – Whoa
Так как только ваше приложение сможет переместить его, и вы можете сделайте это атомарно, вы будете в порядке – segiddins