Reputation: 2625
Am a newbie to iOS programming. This is what am trying to do:
The user enters some text in the screen and it keeps getting added to a UITableView.
As usual, it's getting added from the top.
But I want to add it from the bottom i.e. each new message that's added is added above the rest/existing ones, and not below.
Can someone offer some pointer on this please!
Thanks Priya
Upvotes: 0
Views: 47
Reputation: 10776
Are you using CoreData? If so, maybe you can set a creation time and sort it descending?
If you don't use CoreData but store the data in some sort of array, just add new objects to the beginning of the array and then reload the data.
[array insertObject:data atIndex:0];
Upvotes: 0
Reputation: 960
NSMutableArray's -addObject method appends the object to the end of the array. If you want to put it at the beginning, just use this method instead:
[inputArray insertObject:userInput atIndex:0];
There are other ways to put objects in the array and move them around. Take a look at the documentation:
Upvotes: 1