Objective-C method 'controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:' provided by method 'controller(:didChangeObject:atIndexPath:forChangeType:newIndexPath:)' conflicts with optional requirement method 'controller(:didChangeObject:atIndexPath:forChangeType:newIndexPath:)' in protocol 'NSFetchedResultsControllerDelegate'
func controller(controller: NSFetchedResultsController, didChangeObject anObject: NSManagedObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
if self.collectionView?.window == nil {
return
}
let change = NSMutableDictionary()
switch(type)
{
case .Insert:
change[NSNumber(unsignedLong:type.rawValue)] = newIndexPath
case .Delete:
change[NSNumber(unsignedLong:type.rawValue)] = indexPath
case .Update:
change[NSNumber(unsignedLong:type.rawValue)] = indexPath
case .Move:
change[NSNumber(unsignedLong:type.rawValue)] = NSArray(objects: indexPath!, newIndexPath!)
default:
break
}
self.objectChanges?.addObject(change)
}
It looks like the proper method signature is:
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
}
Any easy way to fix these problems is to allow Xcode to autocomplete the method signature. Then, replace your method's signature with the auto generated signature. For this, you just need to type controller
when defining a method to see the list of all methods that match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With