Objective-C方法'controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:'由方法'controller(:didChangeObject:atIndexPath:forChangeType:newIndexPath :)提供'与可选需求方法'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)
}
Run Code Online (Sandbox Code Playgroud)
小智 11
看起来正确的方法签名是:
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
}
Run Code Online (Sandbox Code Playgroud)
解决这些问题的任何简单方法是允许Xcode自动完成方法签名.然后,用自动生成的签名替换方法的签名.为此,您只需controller在定义方法时键入以查看匹配的所有方法的列表.
| 归档时间: |
|
| 查看次数: |
890 次 |
| 最近记录: |