그래서 배포 대상을 iOS 9 (실제로는 10.0 이하)로 설정하려고하면 제목에 오류가 표시됩니다.Swift 3 - "NSPersistentContainer는 ios 10 이상에서만 사용 가능합니다"
이 문제는 여기에 존재합니다
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "Keebin_development_1")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
내가 아이폰 OS 10을 사용할 수 있는지 여부를 구별하는 몇 가지 코드를 추가 할 필요가 있음이 분명 다른 SO 질문/답변에서 찾고있다. 스위프트 3 자체는
@available(iOS 10.0, *)
을 사용하여 제안합니다. 그래도 충분하지 않습니다. 나는 그것이 "쓸모가 없다면 이것을 사용하지 않을 것"이라고 생각하지만, Swift와 iOS 프로그래밍에 익숙하지 않아 무엇을 구체적으로 쓰는지 모르겠습니다. 그리고 나는 무엇을 써야하는지에 대한 정확한 답을주는 대답을 찾을 수없는 것 같습니다. 누군가 도울 수 있습니까?
을 지원하기 위해이 응답을 따를 수 있는가? 제 3 자 lib가없는 코드를 통해이를 해결할 수있는 방법이 있기를 희망했습니다. –