- (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.item error: property 'item' not found on object of type 'NSIndexPath *' error: 1 errors parsing expression (lldb) po indexPath.row error: property 'row' not found on object of type 'NSIndexPath *' error: 1 errors parsing expression (lldb) po indexPath.section error: property 'section' not found on object of type 'NSIndexPath *' error: 1 errors parsing expression****
任何想法为什么会发生,该怎么做?
解决方法
> 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所述.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。