Last active
August 29, 2015 14:02
-
-
Save kevingriffin/de4a78898e7e3978b991 to your computer and use it in GitHub Desktop.
Swift NSArray indexOfObject (Is there no better way to do this?)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func indexOfObject<T: Equatable>(array: Array<T>, object: T) -> Int? { | |
var i: Int | |
for i = 0; i < array.count; ++i { | |
if (array[i] == object) { | |
return i | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently using in Swift 1.2. I am getting "Overload" error message. Am I doing something wrong?