首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >commitEditingStyle中的NSIndexPath

commitEditingStyle中的NSIndexPath
EN

Stack Overflow用户
提问于 2011-10-31 02:02:46
回答 1查看 499关注 0票数 1

在commitEditingStyle tableView方法中,".row“属性在NSIndexPath上不起作用。有什么想法吗?

这就是调用

代码语言:javascript
复制
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete)
{
    NSLog(@" Delete button pushed. IndexPath:%@",indexPath);  
}}

在表的第三行按下delete按钮时,日志消息为:

‘删除按钮已按下。IndexPath: 2索引0,2’

如果我将日志消息更改为:

代码语言:javascript
复制
NSLog(@" Delete button pushed. IndexPath.row:%@",indexPath.row);

我得到一个编译错误。怎么回事?我以为NSIndexPath有一个'row‘属性。显然,当我检查indexPath时,它就在那里。

库尔特

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-10-31 02:17:52

问题出在您的格式说明符。row属性是整数类型,因此需要使用%d而不是%@

.row属性是UIKit中定义的扩展类别的一部分。

文档是http://developer.apple.com/library/ios/#documentation/UIKit/Reference/NSIndexPath_UIKitAdditions/Reference/Reference.html格式的。

代码语言:javascript
复制
**row**

An index number identifying a row in a section of a table view. (read-only)

@property(readonly) NSUInteger row

**Discussion**

The section the row is in is identified by the value of section.
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7946733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档