相关疑难解决方法(0)

如何在Xcode 8中使用Swift 3创建managedObjectContext?

面对问题"值类型'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来创建它?

xcode core-data ios swift swift3

47
推荐指数
3
解决办法
5万
查看次数

Swift 3中的managedObjectContext

我想通过这个示例代码来处理,其中使用Swift和CoreData来创建表.但是,使用Swift 3我无法使用它.最重要的是,我无法正确更换线路

// set up the NSManagedObjectContext
  let appDelegate = NSApplication.sharedApplication().delegate as! AppDelegate
  managedContext = appDelegate.managedObjectContext
Run Code Online (Sandbox Code Playgroud)

即使我发现了这个相关的问题(然而iOS不是OS X).如何替换产生错误消息的那段代码Value of type 'AppDelegate' has no member 'managedContext'

core-data swift3 macos-sierra

12
推荐指数
3
解决办法
1万
查看次数

Swift 3 IOS 9和IOS 10核心数据

我在我的应用程序中使用核心数据.我希望该应用程序在iOS 9中打开,但事实并非如此.我该如何解决?

在此输入图像描述 在此输入图像描述

本节给出了警告.如何让它在iOS 9和iOS 10上运行?

    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: "IndirimiKovala")
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error as NSError? {
                // Replace this implementation with code to …
Run Code Online (Sandbox Code Playgroud)

ios swift

12
推荐指数
1
解决办法
9147
查看次数

标签 统计

core-data ×2

ios ×2

swift ×2

swift3 ×2

macos-sierra ×1

xcode ×1