0
트위터에서 피드를 가져 와서 구문 분석하려고 시도했습니다. 피드에서 다음 필드 만 필요합니다 : 이름, 설명, time_zone 및 created_at 나는 이름과 설명을 성공적으로 추출하고 있습니다. 그러나 time_zone과 created_at는 항상 nil입니다 ... 다음은 코드입니다 ...TouchXML로 iphone 앱의 트위터 피드를 읽을 수 있습니다.
누구나 이것이 작동하지 않는 이유를 알 수 있습니까?
-(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];
}
미리 도움을 청하십시오 !!
피오나
감사 만 .. 내가 지금 나이 동안 그 쳐다 봤는데 사용 정말로 어리 석다. .. 그러나 다시 감사한다!! – Fiona
Np, 나는 보통 다른 방법으로 그것을 수행하고 if 문에서 무언가를 지정하고 왜 항상 진실인지 궁금해합니다. 해피 코딩 – Rudiger