See if an object exists at index [i] in NSMUtableArray

The people I would like to see if the element in index [i] is not in another (or current) array. So, for example, if my array looked something like this:

[wer, wer4 , wer5 , werp , klo ...

Then I would like to see if aExerciseRef.IDE (for example, sdf) really exists or does not exist in the index [i]. I guess I will have to use some kind of iterator.

for( int i = 0; i < 20; i++ )
{
   if([instruct objectAtIndex:index2 + i] != [instruct containsObject:aExerciseRef.IDE] )                       
   NSLog(@"object doesn't exist at this index %i, i );
   else
   NSLog(@"well does exist")
}

I know that this will not work, just need to clarify what I would like to achieve.

change

I am going to try to clarify this a bit more and be more specific.

1) First of all, changes to aExerciseRef.IDE change every time they are called, so once it is "ret" another time when it is "werd".

2) , aExerciseRef.IDE, , .

, , let, , 2 (wtrk)

[wer, wtrk, wer , sla ... 

, aExerciseRef.IDE.

, .

+3
2

Lord Mighty . , . , .

, :

if (index < [anArray count] && [[anArray objectAtIndex:index] isEqual:anObject]) {
  NSLog(@"Got it!");
} else {
  NSLog(@"Don't have it.");
}

containsObject: :

if ([anArray containsObject:aExerciseRef.IDE]) {
  NSLog(@"Got it!");
} else {
  NSLog(@"Don't have it.");
}

, , :

NSInteger index = NSNotFound;
if ([anArray containsObject:aExerciseRef.IDE]) {
  index = [anArray indexOfObject:aExerciseRef.IDE];
  ...
}
+2

, . (id)

[instruct objectAtIndex:index2 + i]

BOOL

[instruct containsObject:aExerciseRef.IDE]

, , x , , containsObject YES .

, , , , :

if ([[anArray objectAtIndex:index] == anObject])
  NSLog (@"Got it!");
else
  NSLog (@"Don't have it.");
0

Source: https://habr.com/ru/post/1717730/


All Articles