gpt4 book ai didi

swift - 在类型 '' 上使用实例成员 '' ';您的意思是改用 '' 类型的值吗?

转载 作者:行者123 更新时间:2023-11-28 12:35:19 25 4
gpt4 key购买 nike

<分区>

下面的错误是由“let managedObjectContext = getMainContext()”行代码引起的,是什么原因导致的,因为我不明白为什么我不能毫无问题地使用该函数

Use of instance member 'getMainContext' on type 'RoutineController'; did you mean to use a value of type 'RoutineController' instead?

    fileprivate lazy var fetchedExercisesTodayController: NSFetchedResultsController<UserExercise> = {

let managedObjectContext = getMainContext()
let userExercise = UserExercise(context: managedObjectContext)

let fetchRequest: NSFetchRequest<UserExercise> = UserExercise.fetchRequest()
fetchRequest.predicate = NSPredicate(format: "(usersroutine == %@)", self.routineName)
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "id", ascending: true)] //this isnt really needed

let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
fetchedResultsController.delegate = self
return fetchedResultsController
}()

func getMainContext() -> NSManagedObjectContext {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
return appDelegate.persistentContainer.viewContext
}

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