当我尝试声明名为seeder
的变量时,我不知道为什么会出现此错误:
CollectionOnelk。 type没有名为appDelegate的成员
这是我的代码,您可以看到我已经声明var appDelegate
:
import Foundation
import UIKit
import CoreData
class PendingOperations {
var downloadsInProgress = [NSIndexPath:NSOperation]()
var downloadQueue:NSOperationQueue = {
var queue = NSOperationQueue()
queue.name = "Download queue"
queue.maxConcurrentOperationCount = 1
return queue
}()
}
class CollectionOnelk: NSOperation {
var appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
var seeder = CoreDataSeederOne(context: appDelegate.managedObjectContext!)
self.filters = fetchFilters()!
if self.filters.isEmpty {
seeder.seedCoreDataOne()
self.filters = fetchFilters()!
}
}
这是我的CoreDataSeederOne
代码:
import Foundation
import CoreData
class CoreDataSeederOne {
var managedObjectContext: NSManagedObjectContext!
init (context: NSManagedObjectContext) {
self.managedObjectContext = context
}
}