0

I am working on an application that shows news feeds based on different categories. I have a list of categories stored on a server in a XML file which is parsed and its content is stored in a SQLite table.

The structure of the XML looks like this:

<categories>
<category>
<name>Lajme</name>
<image>
http://apps.shqip.mobi/Apps/An/Shqipcom/data/source/img/category/lajmet.png
</image>
<order>1</order>
</category>
</categories>

The idea is that I want to reorder the categories manually, i.e. i want the category "Maqedoni" to be shown above other categories in the news feed. (see screenshots below)

enter image description hereenter image description hereenter image description here

How can i retrieve somehow the current postition of the row and whenever the user moves it up or down to increase or descrease the order number from the database?

I have no idea how to approach this problem because this is one of my first projects. Any help would be appreciated.

Thanks in advance.

Granit.

Granit
  • 1,261
  • 6
  • 19
  • 35
  • does that link help you https://developer.apple.com/library/ios/documentation/userexperience/conceptual/tableview_iphone/ManageReorderRow/ManageReorderRow.html ? it is apple documentation – BergP Oct 07 '13 at 17:38
  • @PavelKatunin I am moving the cells when i enter the edit mode, i just don't know how to save the state of the edited list so that i can use that particular order later in the application where i show the feeds divided into categories. I'll take a look at the link. Thank you – Granit Oct 07 '13 at 17:41
  • So if you use some array (as data source for your table view), you can save that array (or just crteate new NSArray only with names of countries) in documents directory, see http://stackoverflow.com/questions/3829631/is-it-possible-to-save-nsmutablearray-or-nsdictionary-data-as-file-in-ios . Or you can map your objact at data base using Core Data (Core Data is realy good thing), and reorder your data after editing directly in data base (in some persistent storage) – BergP Oct 07 '13 at 17:49
  • Could you show some code, for examle tableView:cellForRowAtIndexPath: method implementation ? – BergP Oct 07 '13 at 17:51
  • @PavelKatunin sure you can find the code for the tableview methods on this link: http://pastebin.com/ZUpstghd – Granit Oct 07 '13 at 17:55
  • Why do you get some fields from arrayOfSource and some fields from categories, why dont you merge thay? So there is link http://stackoverflow.com/questions/812630/how-can-i-reorder-rows-in-sql-database , it is not short solution. So I advice you to use Core Data if it possible. Is aSource.link the remote link? – BergP Oct 07 '13 at 18:07
  • if aSource.link - is remote link. It is not good solution to performe network operation in main thread cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:aSource.link]]]; – BergP Oct 07 '13 at 18:14
  • A possible approach would be to have a NSInteger order property on your object which is set once then setup KVO to monitor when a cell is reorder and save that location index in the order property – Kyle C Oct 07 '13 at 22:12
  • @PavelKatunin yes aSource.link is a remote link where the image is stored. I'm trying to use the link that you posted above to see if it works. – Granit Oct 08 '13 at 07:49

0 Answers0