답변:
를 들어 NSString다음을 사용 :
NSString *myString = [theTextField stringValue];
를 들어 int다음을 사용 :
int myInt = [theTextField intValue];
컨트롤에서 값을 가져 오는 다른 방법이 많이 있습니다. NSControl자세한 내용은 "컨트롤 값 가져 오기 및 설정"섹션 에서 참조를 참조 하십시오 .
다음은 목록입니다.
doubleValuefloatValueintValueintegerValueobjectValuestringValueattributedStringValue또한:
MyObject누군가가에 입력 할 때 알림을 받고자 하는 객체 ( )가 있다고 가정 해 보겠습니다 NSTextField. .h 파일에서 다음 과 같이 MyObject선언해야합니다 NSTextFieldDelegate.
@interface MyObject : NSObject <NSTextFieldDelegate>
그런 다음 MyObject를 NSTextField
[myTextField setDelegate:myObject]
이제 다음과 같이 MyObject에서 메서드를 구현하여 텍스트 필드에서 어떤 일이 발생하는지 확인할 수 있습니다.
-(void)controlTextDidEndEditing:(NSNotification *)aNotification;
-(void)controlTextDidChange:(NSNotification *)aNotification;
-(void)controlTextDidBeginEditing:(NSNotification *)aNotification;