2011-10-30 2 views
1

commitEditingStyle tableView 메서드에서 ".row"속성이 NSIndexPath에서 작동하지 않습니다. 어떤 아이디어? commitEditingStyle의 NSIndexPath

'버튼을 삭제

가 밀어 :

여기에 삭제 버튼이 로그 메시지는 테이블의 세 번째 행에 밀려 호출

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

에게 있습니다. IndexPath : 내가 컴파일 오류가

NSLog(@" Delete button pushed. IndexPath.row:%@",indexPath.row); 

: 2 인덱스 [0, 2] '

나는에 로그 메시지를 변경하는 경우. 뭐라 구요? NSIndexPath에 '행'속성이 있다고 생각했습니다. 인덱스 경로를 확인할 때 분명히 있습니다.

커트

답변

2

문제는 형식 지정자와 함께입니다. row 속성은 정수 유형이므로 %@ 대신 %d을 사용해야합니다.

.row 속성은 UIKit에 정의 된 확장 범주의 일부입니다.

문서는 http://developer.apple.com/library/ios/#documentation/UIKit/Reference/NSIndexPath_UIKitAdditions/Reference/Reference.html입니다.

**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. 
+0

Objective-C ... 기억해 주셔서 감사합니다. 감사합니다. – Kurt

관련 문제