Evgeniy Kleban Evgeniy Kleban - 2 months ago 6x
iOS Question

Substring specific integer from string

I have google some related questions, but unfortunately didn't find answer.

I have string like

, i need to get an integer
, evaluate it to 7 and save.

Of course, this is date, therefore it will change every time, so i cant suppose that year always will be 2016. I need to get string after 5th symbol up to 8th.

Is there any easy way to achieve that? Thanks.


If it's always that section of the string, you can use NSMakeRange(5, 2) and substringWithRange to pick out the month.

After you have "07", conversion is just a case of asking the string for its integerValue.

The "save" part depends entirely on where you want to save it.