-1

私は次のことをしたい:

数字または不明な文字の az と # を含む plist ファイル.. 27 配列。これらの 27 個の配列を辞書、plist ファイルに格納したいと考えています。

文字がディクショナリ配列で表されていないことも発生する可能性があります...

27個の配列を作成して、それらが存在するかどうかを確認する必要がありますか、それとももっと簡単な方法がありますか?

それらをテーブルビューに表示したい..テーブルビューの「a」セクションのキー「a」のすべての値など....

時間とコードを節約する方法はありますか?

私が試すことができる可能性をありがとう

4

1 に答える 1

0

このコードを試す

pList ファイルにデータを書き込む

    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

    NSMutableArray *arr = [NSMutableArray new];

    for (char value = 'a'; value<='z'; value++) {
        [arr addObject:[NSString stringWithFormat:@"%c",value]];
    }

    NSDictionary *dict = [NSDictionary dictionaryWithObject:arr forKey:@"alphabet"];

    [dict writeToFile:filePath atomically:YES]

numberOfSectionsInTableView を設定します

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return [[dict objectForKey:@"alphabet"]count];
}

numberOfRowsInSection を設定します

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

return 1;

}

cellForRowAtIndexPath にセル テキストを設定する

  [[cell textLabel] setText:[[dict objectForKey:@"alphabet"]objectAtIndex:indexPath.section]];
于 2012-12-21T13:19:07.967 に答える