I have got an array, I know how to count its elements, but I need to count elements until a specific word:
NSMutableArray *whatBondInFrame;
whatBondInFrame=[NSMutableArray arrayWithObjects:@"red",@"red",@"red",@"gray",@"red",@"ran",@"gray",@"gray",nil];
I know [ whatBondInFrame count] but, let’s say I want to know how many elements I have till the first gray or from the word “ran”.
How would I get that?
This isn’t tested but it should work:
this gives you the
countfrom the first element named ran.If you want to know how many elements there are before (till) the word ‘ran’ then replace the last line with