Managing data for UITableViews

Managing data for UITableViews

I have two very simple, identical UITableViews in my app that are populated with thumbnail images named "thumb1.jpg", "thumb2.jpg", etc. These thumbnails have associated original images "1.jpg" and text files "1.txt" used for image processing. Everything is stored in the app's Documents folder.

I want to keep the numbered, ordered naming for these files since it makes displaying the thumbnails in the UITableViews very easy with cellForRowAtIndexPath. I'm currently using a NSMutableArray (index: 1 object:"thumb1.jpg", etc) to track all images in the app.

The issue is that users can add/delete images so maintaining the order is important. For handling adding/deleting I'm looking at using insertObjectAtIndex and removeObjectAtIndex on the NSMutableArray, which will maintain order but will require programmatically changing image and text file names when this happens. For example, if there are five images in the array "0.jpg","1.jpg","2.jpg","3.jpg","4.jpg" and the user deletes the second image ("1.jpg") the array will now have "2.jpg" at index 1 so filenames will have to be changed to "1.jpg", "1.txt", and "thumb1.jpg".

How does this approach sound? I'm new to Objective-C so if you have other functions you'd use, etc I'd be interested to hear your opinion.

How to resolve 'unrecognized selector sent to instance'?


How do I enable directional lock for a UIScrollView?
Renaming the actual image files themselves doesn't sound like a good idea..
What mode to use to decrypt RSA message from iPhone in Java?
I would implement 2 NSMutableArrays, one to hold the title/description of the image and one to hold the filename (or, if you wanted, the actual UIImage instead).

What's this {{0,0},{w,h}} doing?
Then if you need to delete, for example the item at index 2, deleting the same object from each of the two arrays will then leave them in sync..
Getting phone UUID through iPhone SDK
If you start wanting more and more things to be stored for each row, I suggest you implement your own class.

Is there a way to use C++ for iPhone development?
You can then implement an array of multiple instances of that class, and each class would have properties such as image, text, thumbnail etc.

Getting the visible rect of an UIScrollView's content
In fact, because you've already named three separate properties (main image, text and thumbnail) I'm tempted to say you should implement a custom class straight away..
Getting first three digits from int/float
Let me know if this makes sense or if you'd like some code to further illustrate it..

66 out of 100 based on 51 user ratings 176 reviews