在我的代码中,我遇到了以下错误代码:
歧义使用'changeDetails(for :)'
你能告诉我如何解决吗?
extension PHChange {
func changeDetails<T: PHObject>(for object: T) -> PHObjectChangeDetails<T>? {
return self.changeDetails(for: object) as! PHObjectChangeDetails<T>?
}
func changeDetails<T: PHObject>(for fetchResult: PHFetchResult<T>) -> PHFetchResultChangeDetails<T>? {
return self.changeDetails(for: fetchResult)
}
}
最佳答案
Photos
框架中已经有两个函数在做相同的事情。如果仍要创建通用版本,则应按如下所示更改外部参数名称:
extension PHChange {
func changeDetails<T: PHObject>(forObject object: T) -> PHObjectChangeDetails<T>? {
return changeDetails(for: object)
}
func changeDetails<T: PHObject>(forObject fetchResult: PHFetchResult<T>) -> PHFetchResultChangeDetails<T>? {
return changeDetails(for: fetchResult)
}
}
关于swift - 歧义使用'changeDetails(for :)',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39351496/