相关疑难解决方法(0)

重写== Equatable类型的函数未调用子类NSCoding和NSObject的自定义类

FooBar下面的类必须覆盖==Equatable类型的功能.

但是,调用对象contains数组FooBar不会导致==调用自定义函数内的断点.是否可能其他==功能覆盖此自定义功能?

注意:因为FooBar必须从NSCoding和NSObject继承,所以FooBar不会将Equatable列为协议,因为它会导致此错误:

'FooBar'与协议'Equatable'的冗余一致性

func ==(lhs: FooBar, rhs: FooBar) -> Bool {
    return lhs.id == rhs.id
}

class FooBar: NSObject, NSCoding {
     // Class def
}

// Both serverFooBars and gFooBars are [FooBar]
let newFooBars = serverFooBars.filter { !gFooBars.contains($0) }
Run Code Online (Sandbox Code Playgroud)

nscoding nsobject swift equatable

17
推荐指数
1
解决办法
6723
查看次数

**'FlickrPhotosViewController'与协议'UICollectionViewDataSource'的冗余一致性**

我正在关注这个(http://www.raywenderlich.com/78550/beginning-ios-collection-views-swift-part-1)教程,现在我

收到此错误:

'FlickrPhotosViewController'与协议'UICollectionViewDataSource'的冗余一致性

所以我在这里有这个代码:

extension FlickrPhotosViewController : UICollectionViewDataSource {

//1
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
    return searches.count
}

//2
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return searches[section].searchResults.count
}

//3
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath)
    cell.backgroundColor = UIColor.blackColor()
    // Configure the cell
    return cell
Run Code Online (Sandbox Code Playgroud)

那么这个错误意味着什么?

任何帮助,将不胜感激.

xcode swift

3
推荐指数
1
解决办法
3661
查看次数

标签 统计

swift ×2

equatable ×1

nscoding ×1

nsobject ×1

xcode ×1