gpt4 book ai didi

swift - 错误代码为 :nil/nil/error

转载 作者:行者123 更新时间:2023-11-28 08:51:10 26 4
gpt4 key购买 nike

<分区>

开始在 SWIFT 中学习编码,每次我使用错误方法时都会出现此错误,请帮助

    var context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
var request = NSFetchRequest(entityName: "Pattern")
var results = context.executeFetchRequest(request, error:nil) // Extra argument 'error' in code
if results != nil {

}

func createTestPatterns(){
var context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
var pattern = NSEntityDescription.insertNewObjectForEntityForName("Pattern", inManagedObjectContext: context) as! Pattern
pattern.name = "Blue Mushroom"
context.save(nil) //call can throw but it is not marked with 'try' and the error is not handled
}

我该怎么办,请帮忙

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com