我按照指示使用Cocoapods(0.39)将Realm.IO(0.97.0)安装到我的项目中。
当我创建一个Swift游乐场(Xcode 7.2)时,有类似的东西:
import RealmSwift
class Unit: Object {
dynamic var name = ""
}
let unit = Unit(value: ["name": "Moya"])
do {
try NSFileManager.defaultManager().removeItemAtPath(Realm.Configuration.defaultConfiguration.path!)
} catch {}
let realm = try! Realm()
realm.beginWrite()
realm.add(unit)
try! realm.commitWrite()
let results = realm.objects(Unit)
results.count
我在控制台中收到错误:
2015-12-28 11:13:13.877 Realm[39396:2067298] Failed to obtain sandbox extension for path=/var/folders/gx/699y9yv15gg2zr5sqtmtpnt80000gp/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.Realm-395D9AEC-443D-446F-AF34-EB74AA840501/Library/Caches/com.apple.dt.playground.stub.iOS_Simulator.Realm-395D9AEC-443D-446F-AF34-EB74AA840501. Errno:1
2015-12-28 11:13:13.878 Realm[39396:2067298] Failed to obtain sandbox extension for path=/var/folders/gx/699y9yv15gg2zr5sqtmtpnt80000gp/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.Realm-395D9AEC-443D-446F-AF34-EB74AA840501/Library/Caches/com.apple.dt.playground.stub.iOS_Simulator.Realm-395D9AEC-443D-446F-AF34-EB74AA840501. Errno:1
游乐场结果本身按预期工作。但是,这个错误很麻烦。我该怎么做才能消除它?
感谢。
答案 0 :(得分:0)
您遇到的错误可能只是Xcode中的一些内部状态损坏,它可能有助于重新启动Xcode和/或清除缓存(如错误消息中所示)。
请注意,using Realm in playgrounds存在一些限制。