2011-04-24 2 views
0

간단한 암호화를 위해 UITextField를 출력으로 사용하려고합니다. 필드는 nil 문자열 (기본 동작)으로 시작하고 encryptButtonPressed: 작업으로 업데이트하려고합니다. 나는 암호문에 좋은 NSString을 가져 왔음을 알고, 오류나 경고 또는 메소드가 존재하지 않지만 필드는 공백으로 남습니다. 어떤 아이디어? 컨트롤러의 구현에 정의IBAction에서 UITextField 값 설정

@interface FirstViewController : UIViewController <UITextFieldDelegate> { 


    IBOutlet UITextField *affineKeyField; 
    IBOutlet UITextField *shiftKeyField; 

    IBOutlet UITextField *messageField; 
    IBOutlet UITextField *ciphertextField; 

    MAAffineMachine* machine; 
} 

@property (nonatomic, retain) UITextField *affineKeyField; 
@property (nonatomic, retain) UITextField *shiftKeyField; 

@property (nonatomic, retain) UITextField *messageField; 
@property (nonatomic, retain) UITextField *ciphertextField; 


@property (nonatomic, retain) UIButton *encryptButton; 
@property (nonatomic, retain) UIButton *clipboardButton; 

- (IBAction)encryptButtonPressed:(id)sender; 
- (IBAction)clipboardButtonPressed:(id)sender; 

@end 

그리고 액션 : 여기

헤더의

- (IBAction)encryptButtonPressed:(id)sender { 
    NSLog(@"Encrypt Button pushed.\n"); 
    int affine = [[affineKeyField text] intValue]; 
    int shift = [[shiftKeyField text] intValue]; 
    NSString* message = [messageField text]; 
    NSLog(@"%d, %d, %@", affine, shift, message); 
    NSString* ciphertext = [machine encryptedStringFromString:message 
                ForAffine:affine 
                 Shift:shift]; 
    NSLog(@"%@\n", ciphertext); 
    [[self ciphertextField] setText: ciphertext]; 
} 

답변

0

ciphertext의 값이 적절한 경우 인터페이스 작성기에서 ciphertextField이 제대로 연결되어 있는지 확인해야합니다.

+0

사실 그건 문제였습니다. 나는 오타로 인해 해당 콘센트의 이름을 리팩터링했으며 링크가 올바르게 업데이트되지 않았다는 사실을 알지 못했습니다. 감사. Xcode 4에 모든 것을 통합 할 때 Xcode 3의 IB에 익숙해지기 시작 했으므로 간단한 몇 가지 사항을 놓치고 있습니다. – matthias

0

시도 [[자기 ciphertextField]의 setText : 암호문] -> [ciphertextField의 setText : 암호문] 또는 cipherTextField.text = ciphertext;