1
我試圖從以下plist輸出結果,其中選中的是1(檢查是來自plist的BOOL)。我遇到的問題是,當我嘗試將文本輸出到提供者數組中時,它會將它們依次輸出,而不是像「text1,text2,text3,」等等一樣排列。如何將plist項目輸出到數組中
我的語法造成我是這個問題。任何幫助都會很棒。
NSString *path = [[NSBundle mainBundle] pathForResource:@"Providers" ofType:@"plist"];
dataArray = [NSMutableArray arrayWithContentsOfFile:path];
for (NSDictionary *dictionary in dataArray)
{
text = [dictionary valueForKey:@"text"];
checked = [dictionary valueForKey:@"checked"];
NSLog(@"%@ checked value is: %@", text, checked);
if ([checked boolValue]) {
NSString *providers = [NSString stringWithFormat:@"%@",text ];
NSLog(@"providers are %@", providers);
NSArray *providersArray = [text componentsSeparatedByString:@","];
NSLog(@"providersArray are %@", providersArray);
}
}
目前尚不清楚你想要做什麼。你是否試圖將文本分隔成以逗號分隔的單詞,並將這些單詞放入數組中?如果是這樣,那麼下一組單詞(來自您的for-in循環中的下一個詞典)會去哪裏? – rdelmar