내가 목표 C 프로그래밍에 큰 얼간이 목장 가이드를 읽고있다 그리고 난 코드를 가지고 : 나는 수익을 indexPath.row 또는 무엇 인덱스가 배열에 표현되는 것을 이해하지indexPath.row는 무엇을 반환합니까?
- (NSInteger) tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [self.tasks count];
}
- (UITableViewCell *) tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// Get a reusable cell
UITableViewCell *c = [self.taskTable dequeueReusableCellWithIdentifier:@"Cell"];
// This below is what i don't understand
NSString *item = [self.tasks objectAtIndex:indexPath.row];
c.textLabel.text = item;
return c;
}
을, 난 그냥이 내가 실제로 작은 응용 프로그램을 만드는 책의 부분에 도달, 그래서 그냥 인덱스에 정수를 전달하는 데 익숙해.
NSString * item = [self.tasks objectAtIndex : indexPath.row];
이 코드가 모두 필요한지는 잘 모르겠지만 질문에 대답하는 데 필요한 모든 코드가 있는지 확인하고 싶습니다.
.H 파일 - http://pastebin.com/TRnPqn4d
하는 .m 파일 - http://pastebin.com/YXZffwye
섹션이 하나 뿐이지 만 indexPath.row는 내 배열에 대해 어떻게 알 수 있습니까? – hanseN
@hanseN 그렇지 않습니다. 배열에 몇 가지 값이 포함되어 있습니다. 그런 다음'numberOfRows' 메쏘드 ('return array.count')에서 이것을 알려줍니다. 그래서 테이블은 많은 행을 생성합니다. 'array [0]'...'array [1]'등의 배열로부터 물건을 얻습니다 ...'indexPath.row'는이 숫자들을 생성합니다. – Fogmeister
그래서 배열에 추가하는 각 객체에 대해 indexPath.row가 하나씩 증가합니까? – hanseN