2014-01-05 2 views
0

UTTableView에 내 Data.plist 파일의 내용으로 채우려고합니다. 이것을 NSMutableArray에로드해야합니다. 이 내가 온 얼마나 멀리입니다 :iOS Plist에서 데이터로 채우기 UITableView

(보기나요로드) :

NSString *PlistPath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; 

    Array = [[NSMutableArray alloc] initWithContentsOfFile:PlistPath]; 

    [Array addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Testing 1", @"name", nil]]; 

그리고 물론 CellForRowAtIndexPath에서 :

cell.textLabel.text = [Array objectAtIndex:indexPath.row]; 

내가 내 Data.plist 파일 (사진)이 쓴 :

http://i.stack.imgur.com/Cs1xd.png

이제 앱을 실행할 때. 내 TableView은 비어 있습니다.

시간과 도움에 감사드립니다!

답변

1

현재 plist의 루트는 Dictionary으로 설정되어 있습니다. 먼저 array으로 변경하십시오.

cell.textLabel.text = [[Array objectAtIndex:indexPath.row] objectForKey:@"name"]; 
+0

감사합니다 순전히 :

그런 다음 데이터를 표시하려면이 코드를 사용! – Ruub020