ios – NSIndexPath不会将项目,部分或行识别为属性

ios – NSIndexPath不会将项目,部分或行识别为属性,第1张

概述当iOS 7.1发送我的viewController时: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath indexPath对象无法识别属性:item,section或row.期望值为sec 当iOS 7.1发送我的vIEwController时:
- (UICollectionVIEwCell *)collectionVIEw:(UICollectionVIEw *)collectionVIEw     cellForItemAtIndexPath:(NSIndexPath *)indexPath

indexPath对象无法识别属性:item,section或row.期望值为section = 0,item = 0

调试器显示:

**indexPath NSIndexPath *   0xc000000000000016 NSObject       _indexes    NSUInteger *    NulL      *_indexes     _length     _reserved   voID *  NulL

日志报告:

(lldb) po indexPath<NSIndexPath: 0xc000000000000016> {length = 2,path = 0 - 0}(lldb) po indexPath.itemerror: property 'item' not found on object of type 'NSIndexPath *'error: 1 errors parsing Expression(lldb) po indexPath.rowerror: property 'row' not found on object of type 'NSIndexPath *'error: 1 errors parsing Expression(lldb) po indexPath.sectionerror: property 'section' not found on object of type 'NSIndexPath *'error: 1 errors parsing Expression****

任何想法为什么会发生,该怎么做?

解决方法@H_502_18@ 不要使用getter / setter点语法,使用括号:

> po [index row]
> po [index section]

编辑

The Swift overlay to the Foundation framework provIDes the IndexPath structure,which brIDges to the NSIndexPath class. The IndexPath value type offers the same functionality as the NSIndexPath reference type,and the two can be used interchangeably in Swift code that interacts with Objective-C APIs. This behavior is similar to how Swift brIDges standard string,numeric,and collection types to their corresponding Foundation classes.

> po index.row
> po index.section

按预期工作.对p对po的评论仍然存在.

值得注意的是,您可以使用Swift中的IndexPath,而不是NSIndexPath,如Apple Documentation所述.

总结

以上是内存溢出为你收集整理的ios – NSIndexPath不会将项目,部分或行识别为属性全部内容,希望文章能够帮你解决ios – NSIndexPath不会将项目,部分或行识别为属性所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1095809.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存