XML 피드의 결과를 보여주는 컬렉션보기가 있습니다. 위대한 작품이지만 XML 피드의 결과를 로컬로 저장해야합니다 (예를 들어 인터넷 연결이없는 경우).XML 피드의 항목을 열거합니다.
원시 피드를 로컬에 저장하는 방법을 알고 있지만 실제로해야 할 일은 이며 XML 피드의 항목을 반복하고 각각을 NS30 항목으로 저장합니다..
올바른 생각인가요? 아니면 유용한 조언이나 조언이 있습니까?
이- (void)startParsing
{
NSXMLParser *xmlparser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://images.apple.com/main/rss/hotnews/hotnews.rss#sthash.TyhRD7Zy.dpuf"]];
[xmlparser setDelegate:self];
[xmlparser parse];
if (_marrXMLDataCollection.count != 0) {
// Save XML to NSData items in background?
[self.collectionView reloadData];
}
}
여기에 공급이 어떻게 생겼는지의 예, 나는 너무 localdata.plist
으로 문서 디렉토리에 저장이있다 : 당신은 그냥 직접 XML을 파일로 저장할 수 있습니다
(
{
link = "\nhttp://www.apple.com/pr/library/2016/04/26Apple-Reports-Second-Quarter-Results.html?sr=hotnews.rss";
pubDate = "\nTue, 26 Apr 2016 14:44:21 PDT";
title = "\nApple Reports Second Quarter Results";
},
{
link = "\nhttp://www.apple.com/final-cut-pro/in-action/trim-editing/?sr=hotnews.rss";
pubDate = "\nWed, 20 Apr 2016 10:05:59 PDT";
title = "\n\nFinal Cut Pro X helps small company delight world\U2019s biggest clients";
},
{
link = "\nhttp://www.apple.com/ipad-pro/?sr=hotnews.rss";
pubDate = "\nMon, 21 Mar 2016 12:00:03 PDT";
title = "\n\nApple Introduces 9.7-inch iPad Pro";
},
{
link = "\nhttp://www.apple.com/iphone-se/?sr=hotnews.rss";
pubDate = "\nMon, 21 Mar 2016 11:58:09 PDT";
title = "\n\nApple Introduces iPhone SE \U2014 the Most Powerful Phone with a 4-inch Display";
},
왜 XML을 저장하지 않습니까? – Wain
@Wain XML을 속성 목록이나 다른 것으로 저장한다고 말하고 있습니까? 이 경우 피드에 사진이 너무 많이 남기 때문에 결국 얼마나 효과가 있을지 잘 모르겠습니다. 결국 NSData 항목 대신/추가적으로 해당 항목을 설정해야합니다. – SRMR
사진은 XML에서 어떻게 나타 납니까? base64 인코딩 된 문자열? – Wain