gpt4 book ai didi

ios - Objective-C 方法' Controller :didChangeObject:atIndexPath:forChangeType:newIndexPath

转载 作者:搜寻专家 更新时间:2023-10-30 22:06:57 24 4
gpt4 key购买 nike

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)
}

最佳答案

看起来正确的方法签名是:

func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {

}

解决这些问题的任何简单方法是允许 Xcode 自动完成方法签名。然后,用自动生成的签名替换您的方法的签名。为此,您只需在定义方法时键入 controller 即可查看所有匹配方法的列表。

关于ios - Objective-C 方法' Controller :didChangeObject:atIndexPath:forChangeType:newIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32790733/

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