Evgeniy Kleban Evgeniy Kleban - 1 year ago 107
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download