Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Chetmun

macrumors newbie
Original poster
Aug 13, 2009
10
0
What's the best way to have a list of text items, tap on one and be able to edit it? How about going to a detail view? But then how do you get your change back into the UITableView?

I suppose this could all be done with SQL or CoreData but since the UITableView is based on an array, can we just edit that element of the array and reset the table view?

Eventually I want the data to be persistent so I'll probably go with CoreData or SQL but for now I just want to go from a list to details, edit the details, and go back to the list.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Usually, something like this is done by having a UITableViewController within a UINavigationController. Then, when the detail view is requested by tapping on a row of the table, pushViewController is called and the new view is presented, with a navigation bar still at the top and a Back button automatically included. I'd suggest checking out one of the tableView-related Sample Apps.
 

Chetmun

macrumors newbie
Original poster
Aug 13, 2009
10
0
Thanks, dejo. Actually the navigation is not the issue for me. It's the data itself. I can get the data from the table row to be in a text field on the detail view. But if that text is edited, how do I get it back into the table view?
 

Chetmun

macrumors newbie
Original poster
Aug 13, 2009
10
0
Update the data source and reload the table.

OK, but the data source is just an array created and populated in the class with the table view. I passed the array and the tapped cell row index to the detail view and that's how I get the text into the text field on that view.

Objective-C is laughing at me. I can't even get the editing text back into that array! Assuming I figure that out, I suppose I would have to go back through the array and reset all the cells a la tableView: cellForRowAtIndexPath. But I wouldn't know in which method/class to put that code.

Course, maybe I should just do this a different way. Is there some kind of "iPhone Way" of doing this sort of thing? I'm not finding anything in my searching so far. Everybody talks about having the table and tapping to a detail view but nobody says anything about editing that data.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Assuming I figure that out, I suppose I would have to go back through the array and reset all the cells a la tableView: cellForRowAtIndexPath.
Just reload the data for the UITableView. cellForRowAtIndexPath will get called automatically for all visible rows.

It really sounds like you are trying to bite off more than you can chew at this point. I'd suggest it's time to step back from the real coding, go (re)learn the basics of Objective-C and iPhone development, and then return to this once you feel you have a better handle on those.
 

Chetmun

macrumors newbie
Original poster
Aug 13, 2009
10
0
Just reload the data for the UITableView. cellForRowAtIndexPath will get called automatically for all visible rows.

It really sounds like you are trying to bite off more than you can chew at this point. I'd suggest it's time to step back from the real coding, go (re)learn the basics of Objective-C and iPhone development, and then return to this once you feel you have a better handle on those.

Thanks, I just don't have the time to learn this stuff right. I wish I could step back but I keep getting things thrown at me and I keep hitting bumps due to my lack of understanding of so many things about Objective-C and the iPhone Way. I've been doing mostly Java on Windows for the last several years.

Usually a code snippet or two is all I need because I get stuck on syntax and the frameworks. When forum folk say where those snippets go, I get a clue that I can build on and getting a little thing to work usually translates to larger things.

I appreciate your comments (and your help!) but this is how I have to operate right now. Thanks again.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Thanks, I just don't have the time to learn this stuff right. I wish I could step back but I keep getting things thrown at me and I keep hitting bumps due to my lack of understanding of so many things about Objective-C and the iPhone Way.
Ok, understood. It's just that you are probably going to find that most posters in the iPhone Programming forum are willing to give you guidance but they will be rather reluctant to just give you out-right solutions. Because then it is just you using their experience to do your coding for you. At least, IMHO. :)
 

ghayenga

macrumors regular
Jun 18, 2008
190
0
Ok, understood. It's just that you are probably going to find that most posters in the iPhone Programming forum are willing to give you guidance but they will be rather reluctant to just give you out-right solutions. Because then it is just you using their experience to do your coding for you. At least, IMHO. :)

I don't think that's what he's asking. I suspect he just wants somehing like this:

Simplest way; make your data array a mutable array.
Add a property to your detail view controller: NSMutableArray *dataArray;
And NSInteger selectedIndex;
Set them before you push the detail viewControllerband then when they edit the text in the detail editfield you have access to the table view controllers data array and can change it there.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I don't think that's what he's asking
Perhaps not. But that was my understanding based on this comment:

Usually a code snippet or two is all I need because I get stuck on syntax and the frameworks. When forum folk say where those snippets go, I get a clue that I can build on and getting a little thing to work usually translates to larger things.

By giving them a code snippet or two and instructions on where to put them, you've probably just supplied them with the solution. At least, I think you would. I get the feeling that the pseudo-code you provided would not be detailed enough for the OP since they don't have time to figure out how to translate that into actual code. I could be totally off-base here, though, so, if I am, my apologies.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.