Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phynet/e2e387e20d94de88edb5 to your computer and use it in GitHub Desktop.
Save phynet/e2e387e20d94de88edb5 to your computer and use it in GitHub Desktop.

##Translate removeObjectAtIndex from NSMutableArray into Array in Swift

If you were wondering how in hearth you could removeObject from an Array declared in Swift... I was in your same predicament. Thankfully there are people out there that came first, and found a solution. I'm goin to translate it here for you all and of course, for me...

###Objective-C code:

[self.selectedRows removeObject:[NSNumber numberWithLong:indexPath.row]];

###Swift Translation.

indexPath.row was my object. In theory you woul use whatever object you need to find and later to remove...

if let index = find(selectedRows, indexPath.row){
     selectedRows.removeAtIndex(index)
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment