毕竟 macos 多个版本,每个版本 xxx.header 里面的方法等 都有些出入, 有新的,也有被删除的方法.
这时候, oc 咋调用呢?
把不同时期的 xxx.header 合并成一个大而全的 xxx.header 调用?
还是有啥其他好办法?
搜了一圈,没搜到.
大神们求指点而已..
]]>let selectIndex = self.photoData.seletedAssetArray.index(of: self.previewPhotoArray[currentIndex]) if selectIndex != nil{ self.rightButton.asyncSetImage(UIImage.zyCreateImageWithView(view: ZYPhotoNavigationViewController.zyGetSelectNuberView(index: "(selectIndex! + 1)")), for: .selected) }
if selectIndex != nil{ if self.rightButton.isSelected == false { let indexPath = IndexPath.init(row: selectIndex!, section: 0) self.photoData.seletedAssetArray.remove(at: self.photoData.seletedAssetArray.index(of: self.previewPhotoArray[currentIndex])!) thumbnailCollectionView.deleteItems(at: [indexPath]) }else{ let indexPath = IndexPath.init(row: selectIndex!, section: 0) thumbnailCollectionView.numberOfItems(inSection: 0) thumbnailCollectionView.insertItems(at: [indexPath]) thumbnailCollectionView.reloadItems(at: [indexPath]) thumbnailCollectionViewCellToggeleSelect(indexPath: indexPath) } }
报错信息: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
网上查了一下,https://stackoverflow.com/questions/19199985/invalid-update-invalid-number-of-items-on-uicollectionview,用了第二个高票答案,但没有用。 第一个高票答案没看懂,大神指点一下,不知道有没有其它方法
]]>求推荐,感谢!
]]>我回答构建一个 NSMutableDictionary<NSString *, NSNumber *>的 static 对象应该就可以解决问题了,用 dispatch_once 保证初始化的线程安全。但是被追问这样的话 NSMutableDictionary 的内存会撑爆,调用量会非常大,怎么优化?
我没答上来,事后也没想明白。内存增大应该是 NSString 的原因,NSNumber 毕竟只是值的变化,能占多少内存。NSMutableDictionary 确实会对 key 进行 copy,我在想什么量级的 NSString 会撑爆内存。
有想法?
]]>