2013-07-23 2 views

답변

1

다른 그 자습서 남아있는 것들 :

은 내가 사용하고 소스 코드입니다. 모든 것이 잘 작동합니다. 그들은 바로 설명 항목을 사용하기 위해 왼쪽 입니다. 권리 ...?

다음은이 튜토리얼에서 진행됩니다

@interface ViewController(){ 

NSXMLParser *parser; 
    NSMutableArray *feeds; 
    NSMutableDictionary *item; 
    NSMutableString *title; 
    NSMutableString *link; 
    NSString *element; 

NSMutableString *desc; // Description . 
} 

그냥이 코드를 붙여 넣습니다. 작품 매력 :

#pragma mark - parsing of RssFeed Values 

-(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ 
    element = elementName; 

    if ([element isEqualToString:@"item"]) { 
     item = [[NSMutableDictionary alloc]init]; 
     title = [[NSMutableString alloc]init]; 
     link = [[NSMutableString alloc] init]; 
     desc = [[NSMutableString alloc] init]; 
    } 
} 

-(void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ 
    if ([elementName isEqualToString:@"item"]) { 

     [item setObject:title forKey:@"title"]; 
     [item setObject:link forKey:@"link"]; 
     [item setObject:desc forKey:@"description"]; 
     [feeds addObject:[item copy]]; 

    } 
} 

-(void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ 
    if ([element isEqualToString:@"title"]) { 
     [title appendString:string]; 
    }else if ([element isEqualToString:@"link"]){ 
     [link appendString:string]; 
    }else if ([element isEqualToString:@"description"]){ 
     [desc appendString:string]; 
    } 
} 


-(void) parserDidEndDocument:(NSXMLParser *)parser{ 
    [self.tableView reloadData]; 
} 

이 매개 변수를 사용하여 제품 설명 어디서나 RSSFeed 항목의 설명을 얻을 수 있습니다. 여기

은 그것의 완성입니다 :

-(void) tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    NSString *string = [feeds[indexPath.row] objectForKey: @"description"]; 

    stringUrl = [feeds[indexPath.row] objectForKey:@"link"]; 
    NSLog(@"Description %@", string); 

    actionSheet = [[UIActionSheet alloc] initWithTitle:string delegate:self cancelButtonTitle:Nil destructiveButtonTitle:@"OK" otherButtonTitles:@"GoTo URL", nil]; 
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent; 

    [actionSheet showInView:self.view]; 

} 

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; 
{ 
    self.actionSheet.delegate = self; 
    switch (buttonIndex) { 
     case 0: 
       NSLog(@"ButtonIndex at 0"); 
       break; 

     case 1: 
      NSLog(@"ButtonIndex at 1"); 
      //Add your Segue functionalities over here to open link on the browser . 

    } 
       break; 
     } 

} 

여기에 어떤 문제가있는 경우, Plz은 알려 :::

+0

를 문자열이 모두 표시 이리저리 "%의 @"을 사용하여 피드의 내용 (링크 및 설명 포함) 설명 만 표시해야하며 가능한 다른 방법이 있습니까? – Siva

+0

모든 설명이 필요하거나 특정 행 (품목)에 대해서만 ... –

+0

설명. 현재 o/p는 다음과 같습니다 : "피드의 URL"다음에 설명이옵니다. – Siva