2013-02-19 5 views
1

사진의 제목이 url 인 RSS 피드가 있으며 그 사진을 만들고 싶습니다. 이 작업을 수행하는 가장 좋은 방법은 무엇입니까? MWPhotoBrowser를 사용하여 사진을 삽입하는 방법은 다음과 같습니다.RSS가 포함 된 iOS 포토 뷰어

self.photos = [NSMutableArray array]; 
[photos addObject:[MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]]]; 
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg"]]]; 
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b.jpg"]]]; 

RSS로 어떻게 할 수 있습니까?

감사합니다.

답변

1

RSS 피드에서 사진 뷰어를 만들려면 MWFeedParser을 살펴볼 것을 권합니다. 각 항목의 제목과 URL을 쉽게 가져 와서 원하는대로 표시 할 수 있습니다.

1 - MWFeedParser이 피드 구문 분석 사용 :

//feedURL would be your Photo RSS Feed 
feedParser = [[MWFeedParser alloc] initWithFeedURL:feedURL]; 

2 - MWFeedParser 위임 방법 didParseFeedItem에서을 사진 배열에 항목의 링크를 추가 :

-(void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item{ 
    if (item) [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:item.link]]]; 
} 

을 이제 사진 배열 MWPhoto를 모두 포함하고 있습니다. 원하는대로 하시겠습니까!

+0

내 편집을 참조하십시오 –

+0

내가 할 수있는 것은 MWFeedParser를 사용하여 RSS 피드의 모든 링크를 잡고 NSMutableArray에 링크를 배치하는 것입니다. 그런 다음 해당 배열의 각 URL에 대해 객체를 photos 배열에 추가합니다.'[photos addObject : [MWPhoto photoWithURL : [NSURL URLWithString : URL]]]; ' – JMarsh

+0

aha! 예제 코드가 있습니까? –