Could help me guys with the following three errors in SwiftCoreDataHelper.swift. I am using xcode 7 but its seems that the code for older versions of xcode. thanks in advance.
1 . . .
line error: let items: NSArray = managedObjectContext.executeFetchRequest(<#T##request: NSFetchRequest##NSFetchRequest#>) error: Call can throw, but it is not marked with 'try' and the error is not handled
class func fetchEntities(className:NSString, withPredicate predicate:NSPredicate?, managedObjectContext:NSManagedObjectContext)->NSArray{
let fetchRequest:NSFetchRequest = NSFetchRequest()
let entetyDescription:NSEntityDescription = NSEntityDescription.entityForName(className as String, inManagedObjectContext: managedObjectContext)!
fetchRequest.entity = entetyDescription
if predicate != nil {
fetchRequest.predicate = predicate!
}
fetchRequest.returnsObjectsAsFaults = false
let items: NSArray = managedObjectContext.executeFetchRequest(<#T##request: NSFetchRequest##NSFetchRequest#>)
return items
}
2 . . .
line error: if managedObjectContext.save(nil) {
error: Nil is not compatible with expected argument type '()'
class func saveManagedObjectContext(managedObjectContext:NSManagedObjectContext)->Bool{
if managedObjectContext.save(nil) {
return true
}
else {
return false
}
}
3 . . .
line error: if storeCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error:&error ) != nil {
error: Contextual type '[NSObject : AnyObject]' cannot be used with array literal
if storeCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error:&error ) != nil {
if error != nil {
print(error!.localizedDescription)
abort()
}
}