Ready to Level-Up?

This just in! If your rusty iOS skills could use some refining, or if you're just starting out and you want to level-up fast, consider signing up for our upcoming iOS Screencasts

New from iOS Rocket Surgery Swift Video Tutorials: The rapidly evolving Apple-iOS ecosystem has just been thrown into tumult with the recent introduction of the Swift Programming Language. Are you ready to finally try iOS development? Are you needing to switch from Objective-C to Swift? Sign up today for our free video courses!
(By the dear folks at Swift Tutorial Videos, a sister company)

Thursday, December 19, 2013

iOS Get Selected Rows in a UITableView

So, you want to know what rows are currently selected in a UITableView, huh?

If you're using a tableview to allows single-selection but you do not segue to another controller with the selected record, you may find the need to know what rows are currently selected. If that is your aim, then have no fear, I have some code for you here:


  NSIndexPath *selectedRowPath = [self.tableView indexPathForSelectedRow];


Now, if your tableview's datasource is an array that is a property of your current ViewController, then all is well, and you can get the Object that is actually representative of the selection in the table like so:


  int rowIndex = selectedRowPath.row;  
  NSObject *selectedObject = [self.datasourceArray objectAtIndex:rowIndex];


Hopefully that sets you back on the road to creating value. Speaking of, if you have a mind to give us a +1, please do so, as it creates a lot of value for us. Thank you!






About Me

Easy NSDateFormatter Tool

Save yourself some time in formatting your NSDates to NSStrings, and use the Blind NSDate app, which you can download from iTunes. There's also a website where you can format your NSDates: http://www.blindnsdate.com

Popular Posts

Designed By Seo Blogger Templates