views:

35

answers:

1

I have a question; in my program if i call 2 times

[self performSelectorOnMainThread:@selector(callDectectionMove:) withObject:[NSNumber numberWithInt:(int)i] waitUntilDone:false];

I create 2 thread or not? Because in my program i'm not sure to create 2 threads.
Thanks

-(void)callDectectionMove:(NSNumber*)arrayIndex{

 NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] init];  
 [myDictionary setObject:arrayIndex forKey:@"arrayIndex"];  

 identificationMove *identifier = [[identificationMove alloc]init];
 [identifier setArrayIndex:(NSNumber*)arrayIndex];
 [identifier detectionMove];

 [identifier release];     
}


-(void)detectPositionMovement{


 for(int i = 0; i< [self.arrayMovement count]; i++){

  if((actualAccelerometerX+sensibilityMovement) > [[[[self.arrayMovement  objectAtIndex:i] arrayPositionMove]objectAtIndex:0] valueX] && (actualAccelerometerX-sensibilityMovement) < [[[[self.arrayMovement  objectAtIndex:i] arrayPositionMove]objectAtIndex:0] valueX] &&
     (actualAccelerometerY+sensibilityMovement) > [[[[self.arrayMovement  objectAtIndex:i] arrayPositionMove]objectAtIndex:0] valueY] && (actualAccelerometerY-sensibilityMovement) < [[[[self.arrayMovement  objectAtIndex:i] arrayPositionMove]objectAtIndex:0] valueY] &&
     (actualAccelerometerZ+sensibilityMovement) > [[[[self.arrayMovement  objectAtIndex:i] arrayPositionMove]objectAtIndex:0] valueZ] && (actualAccelerometerZ-sensibilityMovement) < [[[[self.arrayMovement  objectAtIndex:i] arrayPositionMove]objectAtIndex:0] valueZ])
   [self performSelectorOnMainThread:@selector(callDectectionMove:) withObject:[NSNumber numberWithInt:(int)i] waitUntilDone:false];

  }
}
+2  A: 

The method performSelectorOnMainThread won't create new thread it just dispatches selector on main thread. to create new thread use detachNewThreadSelector:toTarget:withObject:

Devara Gudda
Read NSThread -> http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/Reference/Reference.html
Girish Kolari