我正在解析來自服務器的信息,並且已經下載了所有信息,但有一段艱難的時間試圖弄清楚如何將信息添加到表視圖。基本上我想知道的是如何獲取我擁有的信息並將其添加到NSMutableArray中,然後對該對象進行計數並將其添加到表視圖中,但是每次將我的字符串添加到可變數組中時,我什麼都得不到......但我知道所有的信息正在被我的日誌正確解析,並且我只是爲了測試而放置了一個標籤......這裏是我用來獲取信息的代碼。我怎樣才能把我使用的字符串填充到我的表格視圖中?用XML數據填充UITableView
-(void)parser:(NSXMLParser*)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict{
NSLog(@"Parser Was Called");
if ([elementName isEqualToString:@"element"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"themeName"]);
themeNameString = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"themeName"]];
//Test first string
label.text = themeNameString;
}
if ([elementName isEqualToString:@"element1"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"creator"]);
themeCreator = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"creator"]];
}
if ([elementName isEqualToString:@"element2"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"price"]);
themePrice = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"price"]];
}
if ([elementName isEqualToString:@"element3"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"twitterName"]);
creatorTwitterName = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"twitterName"]];
}
if ([elementName isEqualToString:@"element4"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"themeURL"]);
cydiaLink = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"themeURL"]];
}
if ([elementName isEqualToString:@"element5"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"themeDeciption"]);
deciption = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"themeDeciption"]];
}
if ([elementName isEqualToString:@"element6"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"themeScreenShots"]);
screenShots = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"themeScreenShots"]];
}
if ([elementName isEqualToString:@"element7"]) {
NSLog(@"elements recieved %@", [attributeDict objectForKey:@"promo"]);
tblViewImage = [NSString stringWithFormat:@"%@", [attributeDict
objectForKey:@"promo"]];
}
}
請將代碼放在代碼標籤中。 – dasdom