Objective c 解析.plist项
当我试图分析一些奇怪的事情时 我在数我的物品Objective c 解析.plist项,objective-c,ios,cocoa-touch,Objective C,Ios,Cocoa Touch,当我试图分析一些奇怪的事情时 我在数我的物品 NSString *bundlePathofPlist = [[NSBundle mainBundle]pathForResource:@"Mything" ofType:@"plist"]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:bundlePathofPlist]; NSArray *dataFromPlist = [dict
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);
这非常有效,但在-(UITableViewCell*)tableView:(UITableView*)tableView cell for rowatinexpath:(nsindepath*)indepath{
我试过了
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,
)
在我的tablecell中,它也显示为
(
Yeah,
Trol,
LOL,
)
所以你有
( yeah, trol, lol )
…在一个单元格中,对吗?现在,这是很自然的。如果您阅读了NSLog的
或NSString的
文档,您会发现,%@
格式说明符调用对象的描述方法,而对于NSArray
对象,该方法是一个用括号括起来的逗号分隔的列表……同样对其对象的描述
你可能想要的是
cell.Data.text = [dataFromPlist objectAtIndex:indexPath.row];
所以你有
( yeah, trol, lol )
…在一个单元格中,对吗?现在,这是很自然的。如果您阅读了NSLog的
或NSString的
文档,您会发现,%@
格式说明符调用对象的描述方法,而对于NSArray
对象,该方法是一个用括号括起来的逗号分隔的列表……同样对其对象的描述
你可能想要的是
cell.Data.text = [dataFromPlist objectAtIndex:indexPath.row];
(是的,Trol,LOL,)
在一个单元格中,它需要在一个单元格中显示每个单元格@H2CO3(是的,Trol,LOL,)
在一个单元格中,它需要在一个单元格中显示每个单元格@H2CO3@Daniel相信我,用括号括起来很好(不管怎么说,我更喜欢美国英语).头发意见。来自英国,这只是我一直正确的事情,如果代码格式在那里,我就不会这么做。该死,我总是说“让我们拼写正确”,我说“头发意见”而不是“公平意见”@Daniel我刚刚主持了一个建议编辑,其作者声称有“固定语法”…@Daniel相信我,括号中的是好的(而且不管怎样,我在谈论它时更喜欢美国英语)。头发意见。来自英国,这只是我一直正确的一件事,如果代码格式在那里,我就不会这么做。该死,这就是我的全部“让我们拼写正确吧”,我说的是“头发意见”而不是“公平意见”@Daniel我刚刚主持了一个建议编辑,其作者声称有“固定语法”。。。