tags:

views:

52

answers:

2

Hi everyone, I've tried to find some info on the Internet, but couldn't. I'm new to iphone development, but I have already learnt something. I've created application which parses RSS feed and shows it, but I haven't got a clue how to show user which items he has already read and which hasn't. I have some ideas but I don't know are they good or ridiculous. May be someone knows how it is usually done in many existing RSS readers.

Thank you a lot))

A: 

The application will need to store information on which items have been read. Perhaps store the <guid> element of the item.

Chris Diver
Ok, thanks for quick reply, I thought about it, I have another question then, suppose the feed was refreshed and I download and parse it again, creating new array in memory. There are some old items and some new items, how can I save state of old items and apply it to new array? Do I need some kind if nested foreach loop or it can be done more simple? sorry if I write not very clear ))Thanks
Burjua
+1  A: 

The easies way is to store all rss ids in NSUserDefault. Then when the application is loaded, they just load it to a NSSet, and check against the rss list

The other way is to have an attribute called isRead in the RSS news object (if you model your data in such a way), then serialize all the news using NSCoding with encodeWithCoder and initWithCoder to write and get back all objects and their attributes

vodkhang
Thank you very much, if I'm parsing my RSS to array of say NSdictionaries , is there some standard way to check it against NSSet? or should I use foreach loop?
Burjua
If you put your rss to an array (or dictionary), you can do a loop through the whole array to get an id of each element then you [set containsObject:id] to check if that id is in set or not. If you are scared of performance, the overall performance is O(n) for looping arrays and O(1) for containsObject
vodkhang
thanks, is there any better/easier way to keep RSS apart from in array?
Burjua
What do you mean? I don't get it, you want to store RSS list in some data structure?
vodkhang
Sorry if it's not clear) I have an RSS feed which I need to dispay in my app. I think it's naturally enough to parse it and put it in NSMutableArray to display and serialize it to file afterwards. Is there any other way to do it? Your phrase "If you put your rss to an array..." made me ask this question ) Thank you
Burjua
It would make much more sense to parse the RSS and store it into Core Data, not just a plain NSMutableArray. What happens when you get a huge RSS feed? Your way will run out of memory and crash.
jamone
yeah, that's right. But for a newbie, I think introducing that concept is quite more complex. I hope that Aristarh is not doing commercial project because he said he is a newbie in iphone dev. http://developer.apple.com/iphone/library/documentation/DataManagement/Conceptual/iPhoneCoreData01/Introduction/Introduction.html
vodkhang
thank you guys, you gave me some stuff to study and consider)
Burjua