1

何かを解析しようとすると、奇妙なことが起こります。

でアイテムを数えています

NSString *bundlePathofPlist = [[NSBundle mainBundle]pathForResource:@"Mything" ofType:@"plist"];

     NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:bundlePathofPlist];

        NSArray *dataFromPlist = [dict valueForKey:@"some"];

      NSMutableArray *data = [NSMutableArray array];
    for(int i =0;i<[dataFromPlist count];i++)
    {
        //NSLog(@"%@",[dataFromPlist objectAtIndex:i]);
        [data addObject:[NSNumber numberWithInt:[dataFromPlist count]]];
    }
    [self setTableData:data];

        NSLog(@"%@", tableData);

その後:

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

    return [tableData count];
}

これはうまく機能しますが、その後- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

私は試した

NSString *bundlePathofPlist = [[NSBundle mainBundle]pathForResource:@"Mything" ofType:@"plist"];

NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:bundlePathofPlist];

NSArray *dataFromPlist = [dict valueForKey:@"some"];


NSLog(@"%@", dataFromPlist);

cell.Data.text = [NSString stringWithFormat:@"%@", dataFromPlist];

return cell;

しかし、出力は次のとおりです。

2012-08-13 23:08:48.130 [30278:707] (
    Yeah,
    Trol,
   LOL,

)

そして、私のテーブルセルでは、次のようにも表示されます

(
        Yeah,
        Trol,
       LOL,

    )
4

1 に答える 1

1

だからあなたは

( yeah, trol, lol )

... 1つのセルでね?さて、それは当然です。ドキュメントを読んだり、ドキュメントを読んNSLog'sだりした場合は、フォーマット指定子がオブジェクトのdescriptionメソッドを呼び出すNSString'sことがわかります。これは、オブジェクトの場合、かなり括弧で囲まれたコンマ区切りのリストです...繰り返しますが、そのオブジェクトの説明です。 。%@NSArray

あなたがおそらく欲しいのは

cell.Data.text = [dataFromPlist objectAtIndex:indexPath.row];
于 2012-08-13T21:27:28.750 に答える