여러 함수 사이에 무언가를 정의하는 방법이 있습니까? 내가 정의 할 수 있지만 {} 밖에서는 사용할 수 없습니다. UITextField가 만든 코드의 텍스트를 가져올 수 있어야합니다. 내가 사용하고 아래의 코드는 다음과 UIAlertView 안에 텍스트 상자로 하여 myTextField을 정의하는 기능입니다함수간에 정의 유지하기
- (void)AlertShow32 {
UIAlertView * alert = [[ [ UIAlertView alloc ] initWithTitle:@"The Most Annoying Button!" message:@"What's your name?"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil ]autorelease];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:myTextField];;
// [myTextField release];
[alert show ];
}
.
그러나 myTextField 텍스트를 나중에 코드에서 필요한 위치와 같이 나중에 함수에서 액세스 할 수있는 데이터로 저장할 수 있기를 원합니다. 이 도움 넣다
- (void)AlertShow33 {
UIAlertView * alert = [[[[ UIAlertView alloc ] initWithTitle:@"The Most Annoying Button!" message:@"Nice to meet you %i, you have a wierd name!", myTextField.text ]
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil ]autorelease];
alert.transform = CGAffineTransformTranslate(alert.transform, 0.0, 0.0);
[alert show ];
}
, 내가있는 다른 함수에서 다른 함수를 호출 :
만이 함수를 호출하는 부분입니다if (Alerttime == 31) {
[self performSelector:@selector(AlertShow31) withObject:self afterDelay:0.01];
}
if (Alerttime == 32) {
[self performSelector:@selector(AlertShow32) withObject:self afterDelay:0.01];
}
,하지만 난에 에게 Alerttime 정의 :
#define int *Alerttime;
Alerttime = 0;
누구나 내가 텍스트에 액세스하는 방법에 대한 아이디어가 있습니까 myTextField af 기능 은요?
아, 함수간에 코드 정의 된 객체의 텍스트를 유지하지 않을 것이라고 생각했는데, 각 함수가 기본값으로 시작한다고 생각했습니다. – cowbear16
자기 선 사용에 대해 잊어 버렸습니다. 감사합니다. – cowbear16