我试图使用UITextField作为简单加密的输出。该字段以零字符串(默认行为)开始,我尝试在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];
}
那实际上是这个问题;由于输入错误,我重构了该插座的名称,但没有发现链接没有正确更新。谢谢。当我将所有东西都集成到XCode 4中后,我开始习惯于XCode 3的IB,所以我错过了一些简单的事情。 – matthias 2011-04-25 03:53:23