1
글로벌 구성을 만들어 다음과 같은 코드가 있습니다영역이 : 데이터베이스 이름
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
var config = Realm.Configuration()
config.fileURL = config.fileURL!.URLByDeletingLastPathComponent?
.URLByAppendingPathComponent("HelloWorld.realm")
Realm.Configuration.defaultConfiguration = config
return true
}
나는 AppDelegate
의 영역에 대한 기본 이름을 설정하고있어합니다. 내의 ViewController 영역이 자신의 상태의이 새로운 객체이기 때문에
class LoadingScreenViewController: UIViewController {
let realm = try! Realm()
override func viewDidLoad() {
super.viewDidLoad()
//The config (HelloWorld.realm) is printed
print(Realm.Configuration.defaultConfiguration)
//The config (default.realm) is printed
print(self.realm.configuration)
}
}
어쩌면 그건 : 내가 지금처럼 내의 ViewController의 새로운 영역 개체를 만들 때이 이름/설정이로드되지 않습니다. 그렇다면 Singleton을 만들어야합니까? 그리고 그렇게한다면 비동기 적으로 DB에 쓰는 것을 처리 할 수 없다는 것을 의미하지는 않을 것입니다.
작품을, 감사합니다! – Hapeki