본문 바로가기

블로그/아이폰/iOS

AFNetworking으로 RSS 받기.

//AFNetworking 부분.

manager = [AFHTTPRequestOperationManager manager];

manager.responseSerializer = [AFXMLParserResponseSerializer new];

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/rss+xml"];


NSDictionary *parameters = @{};

    

[manager GET:@"URL" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {

        

    [(NSXMLParser*)responseObject setDelegate:self];

    [(NSXMLParser*)responseObject parse];

        

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    NSLog(@"Error: %@", error);

}];


#pragma mark - XMLParserDelegate

-(void)parserDidEndDocument:(NSXMLParser *)parser{

    //parse끝남.

}


-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{


}


-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{

    


    

}