Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ulquiorra

macrumors member
Original poster
People I'd like to see if an element at index is not present in a different (or current ) array. So for instance if my array looked somewhat like this

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

Then I would like to see if aExerciseRef.IDE ( which is "sdf" for instance ) does or does not exist at index. I assume I'd have to use some sort of iterator ..

Code:
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 this doesn't work , it's just to elaborate what I'd like to achieve.

edit:


Let me elaborate a bit more
I'm (again ) using XML parser for this one😉.

@HarryPotter thanks for your answer but that's not what I want to achieve.

@dejo aExerciseRef is a class I'm using to fill different attributes ( just like the Books class in the this example http://www.iphonesdkarticles.com/2008/11/parsing-xml-files.html )

example
Code:
		if( aworkout != nil )
		{
		aExerciseRef = [[exerciseref alloc] init];
		aExerciseRef.IDE = [attributeDict objectForKey:@"id"];
		aExerciseRef.header = [attributeDict objectForKey:@"header"];

To elaborate a little further

Imagine an array being filled with aExerciseRef.IDE's then I would like to compare if the elements in this array exist in the instruct array.

So I would like to see if the element at let's say position 2 (wtrk).
Code:
[wer, wtrk, wer , sla ...

exists in the array which was being filled with the aExerciseRef.IDE's.

note: I'm using the same array here so not a different one that I'm filling. So i'm actually comparing if AN aExerciseRef.IDE is present at location index.
 
no, you use

Code:
[B]if ([yourArray containsObject:myObject])
[/B]  yes, the array contains the object
else
  no... the object is not on the array...
 
@dejo aExerciseRef is a class I'm using to fill different attributes ( just like the Books class in the this example http://www.iphonesdkarticles.com/2008/11/parsing-xml-files.html )

example
Code:
		if( aworkout != nil )
		{
		aExerciseRef = [[exerciseref alloc] init];
		aExerciseRef.IDE = [attributeDict objectForKey:@"id"];
		aExerciseRef.header = [attributeDict objectForKey:@"header"];

To elaborate a little further

Imagine an array being filled with aExerciseRef.IDE's then I would like to compare if the elements in this array exist in the instruct array.

So I would like to see if the element at let's say position 2 (wtrk).
Code:
[wer, wtrk, wer , sla ...

exists in the array which was being filled with the aExerciseRef.IDE's.

note: I'm using the same array here so not a different one that I'm filling. So i'm actually comparing if AN aExerciseRef.IDE is present at location index.

So you have two arrays and you want to see if the objectAtIndex:i from the first array exists (somewhere) in the second array? Is that correct?
 
yes dejo that's correct.

And what I did was create something like this

Code:
for( int i = 1; i <= 5; i++ )
	{
		for( int j = 0; j < [aExerciseRefarray count]; j++ )
			{
			if([instruct objectAtIndex:index2 + i] != [aExerciseRefarray objectAtIndex:j]){
			...

with the aExerciseRefArray filled with aExerciseRef.IDE's.

However this doesn't seem to work.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.