2012-03-01 5 views

답변

4

NSArray 또는 NSDictionary 래퍼 객체를 만들고 전달해야하는 여러 객체가 있고 userInfo에 래퍼 객체를 전달하십시오. 리시버에서 랩퍼 오브젝트에서 오브젝트를 검색하십시오.

래퍼에 대한 NSDictionary와를 사용하여

예제 코드 :

국가 번호 :

NSString *obj1 = @"string1"; 
NSString *obj2 = @"string2"; 
NSDictionary *wrapper = [NSDictionary dictionaryWithObjectsAndKeys:obj1, @"Object1", obj2, @"Object2", nil]; 
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFireMethod:) userInfo:wrapper repeats:NO]; 

받기 타이머 코드 :

- (void)timerFireMethod:(NSTimer*)theTimer { 
    NSDictionary *wrapper = (NSDictionary *)[theTimer userInfo]; 
    NSString * obj1 = [wrapper objectForKey:@"Object1"]; 
    NSString * obj2 = [wrapper objectForKey:@"Object2"]; 
    // ... 
} 
관련 문제