0

plist の配列のキーをテーブルのラベルとして使用しようとしています。これは私がこれまでに試したことです。ivar を宣言しました。NSArray *viewerKeys;

ビューでDidLoad

`NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Data.plist"];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithContentsOfFile:(NSString *)plistPath];
viewerKeys = [dictionary allKeys];`

および cellForRowAtIndexPath で UILabel *label = (UILabel *)[cell viewWithTag:1000]; label.text = [viewerKeys objectAtIndex:indexPath.row];

viewdidload から viewerKeys をログに記録できますが、NSLog@"%@", [viewerKeys objectATIndex:indexPath.row]何も取得しようとしても、null でさえありません。

4

1 に答える 1

0

numberOfRowsInSectionを正しくカウントしていませんでした。私の間違い!

于 2013-02-14T13:45:37.880 に答える