My NSArray
contains a day of the week followed by space and a number. The array looks like this:
(
"Monday 1 - Rapids",
"Monday 2 - Durango Shopping",
"Monday - Train"
)
What I need to do is to scan through the array for the one with the highest number, and delete everything else. Any thoughts?
There are various ways to do this.
You could use componentsSeparatedByString: @" "
to break each item into words and then take intValue of the second item in each resulting array. That would be easy, but use rather a lot of temporary memory and probably be kind of slow.
You could write code using NSScanner to extract the item between the first and second spaces.
You could write a regular expression that would match on the second word and return an empty room sting if it's not a number. (You'd make the number a "capture group".)