我想检查用户是否在低于5.0的iOS上运行应用程序并在应用程序中显示标签.
如何以编程方式检测用户设备上运行的iOS?
谢谢!
面对问题"值类型'AppDelegate'没有成员'managedObjectContext'在新的Xcode 8中(使用Swift 3,iOS 10)尝试在View Controller中创建新的上下文时
let context = (UIApplication.shared().delegate as! AppDelegate).managedObjectContext
Run Code Online (Sandbox Code Playgroud)
在Xcode 8中,AppDelegate.swift文件中没有managedObjectContext的代码.AppDelegate.swift中的核心数据堆栈代码仅显示:lazy var persistentContainer:NSPersistentContainer属性和func saveContext().没有managedObjectContext属性.
如何在Xcode 8)中使用Swift 3创建managedObjectContext,或者可能没有必要使用Swift 3来创建它?
因此,当我尝试将部署目标设置为iOS 9时(实际上低于10.0),我会收到标题中所述的错误.
这里存在的问题是:
// 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 …Run Code Online (Sandbox Code Playgroud) ios ×3
core-data ×2
swift3 ×2
cocoa-touch ×1
ios4 ×1
iphone ×1
objective-c ×1
swift ×1
xcode ×1