1

質問があります; 私のプログラムで2回電話すると

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

2つのスレッドを作成するかどうか?私のプログラムでは、2つのスレッドを作成するかどうかわからないためです。
ありがとう

-(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];

  }
}
4

1 に答える 1

4

メソッドperformSelectorOnMainThreadは新しいスレッドを作成せず、メインスレッドでセレクターをディスパッチするだけです。新しいスレッドの使用を作成するdetachNewThreadSelector:toTarget:withObject:

于 2010-07-27T09:10:00.033 に答える