1

I have a really long string, and I would like to look up some words and characters. Is there a function in Objective C that is equivalent to c#?

string string name; string[0];

2 Answers 2

2

Yes, it is called characterAtIndex:

NSString s = @"hello";
char c = [s characterAtIndex:3];
Sign up to request clarification or add additional context in comments.

Comments

0

I think this is a bit better if you want to look for both characters and words. The characterAtIndex is intended to use only for single char only and makes you add an iteration through the string and check each one for what you're looking for.

NSRange range = [@"test12" rangeOfString:@"t12"];
NSLog(@"Position %d: Length %d", range.location, range.length);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.