Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Access Array Element for Selected Row

Hello all, I am trying to get the array element of an array at the index of the selected row so I can edit it.

I create an IndexPath property in the .h and then in the .m I passed the IndexPath parameter to the indexPath property. Then in the unwind segue that will access and edit the array element for the selected row, I tried to use this:

UITheViewController* source = [segue sourceViewController]; String theElement = source.nameOfElement; [self.theArray replaceObjectAtIndex:[self.IndexPath.row] WithObject:[theElement];

[self.tableView reloadData];

I tried to use this code but it wouldn't work.What am I doing wrong and/or what do I need to fix or do differently? Thank you!

1 Answer

UITheViewController *source