TouchXML leggere twitter di alimentazione per iPhone
Domanda
Così sono riuscito a ottenere il feed da Twitter e sto cercando di analizzarlo ... Ho bisogno solo i seguenti campi del feed: nome, descrizione, time_zone e created_at Sto tirando con successo il nome e la descrizione .. comunque time_zone e created_at sempre sono pari a zero ... Quanto segue è il codice ...
Chiunque veda il motivo per cui questo potrebbe non essere di lavoro?
-(void) friends_timeline_callback:(NSData *)data{
NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"Data from twitter: %@", string);
NSMutableArray *res = [[NSMutableArray alloc] init];
CXMLDocument *doc = [[[CXMLDocument alloc] initWithData:data options:0 error:nil] autorelease];
NSArray *nodes = nil;
//! searching for item nodes
nodes = [doc nodesForXPath:@"/statuses/status/user" error:nil];
for (CXMLElement *node in nodes)
{
int counter;
Contact *contact = [[Contact alloc] init];
for (counter = 0; counter < [node childCount]; counter++)
{
//pulling out name and description only for the minute!!!
if ([[[node childAtIndex:counter] name] isEqual:@"name"]){
contact.name = [[node childAtIndex:counter] stringValue];
}else if ([[[node childAtIndex:counter] name] isEqual:@"description"]) {
// common procedure: dictionary with keys/values from XML node
if ([[node childAtIndex:counter] stringValue] == NULL){
contact.nextAction = @"No description";
}else{
contact.nextAction = [[node childAtIndex:counter] stringValue];
}
}else if ([[[node childAtIndex:counter] name] isEqual:@"created_at"]){
contact.date == [[node childAtIndex:counter] stringValue];
}else if([[[node childAtIndex:counter] name] isEqual:@"time_zone"]){
contact.status == [[node childAtIndex:counter] stringValue];
[res addObject:contact];
[contact release];
}
}
}
self.contactsArray = res;
[res release];
[self.tableView reloadData];
}
Grazie in anticipo per il vostro aiuto !!
Fiona
Soluzione
potrebbe essere un errore, ma perché sono uguali doppie (==), di solito utilizzati per una condizione di controllo
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow