3

How do i get index value from NSMutableArray.

I got NSString *stringValue=@"e";

And my NSMutableArray *arrayValue=[[NSMutableArray alloc]init];

[arrayValue addobject:@"a"];
[arrayValue addobject:@"b"];
[arrayValue addobject:@"c"];
[arrayValue addobject:@"d"];
[arrayValue addobject:@"e"];
[arrayValue addobject:@"f"];
[arrayValue addobject:@"g"];

I want to get array index value based on string value.

How to do

@thanks in advance.

2 Answers 2

9

Wow, a quick look at the documentation ?

NSUInteger index = [ar indexOfObject:@"e"];
Sign up to request clarification or add additional context in comments.

Comments

1

Since NSMutableArray is a NSArray subclass, all the methods are also inherited. You're looking for the indexOfObject: function

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.