Hema
Hema

Reputation: 947

Searching for a specific last character in a string

I would like to search for a specific last character in a NSString and couldn't figure out a way. In C# for example, I can do lastindexof to get the index of the char I'm searching for and then use substring to get what I want. Is there a way in Obj C to achieve this?

Upvotes: 0

Views: 109

Answers (1)

Dmitry Shevchenko
Dmitry Shevchenko

Reputation: 32414

NSString *s = @"aabbcc";
[s rangeOfString:@"b" options:NSBackwardsSearch]; // {3, 1}

Upvotes: 1

Related Questions