Objective-C에서 특정 규칙에 따라 인스턴스 이름을 얻는 방법은 무엇입니까?String을 사용하여 instanceName을 얻는 방법
타입 1 : 루프 GET 번호에 self.btn (0,1,2,3,4,5,6,7,8,9 ...)
을 해제 i 행 예for(int i = 0; i<10; i++){
//wrong code (similar ActionScript3.0 code)
self."btn"+i = [UIButton buttonWithType:UIButonTypeRoundRect];
//i think code but, not available
self.[NSString stringWithFormat:@"btn%d", i] = [UIButton buttonWithType:UIButtonTypeRoundedRect];
}
타입 2 : 그래서
for(int i =0; i<10; i++){
//wrong code (similar ActionScript3.0 code)
UIButton *"btn"+i = [UIButton buttonWithType:UIButtonTypeRoundRect];
//i think code but, not available
UIButton *[NSString stringWithFormat:@"btn%d", i] = [UIButton buttonWithType:UIButtonTypeRoundedRect];
}
에서에서 루프에있는 UIButton의 *의 BTN (0,1,2,3,4,5,6,7,8,9 ...) 얻을 수 ActionScript3.0 소스가 아래에 있습니다.
for(var i=0; i<10; i++){
this["btn"+i] = new SimpeButton();
//btn0, btn1, btn2...btn10 get by for loop i object Simpebutton ten.
}