开发者

Problem with NSScanner in the IB connections

This maybe a silly question, but I am having a problem with the NSScanner. I have a UITextField in which the text needs to be taken. I cannot seem to get the NSScanner field connected in Interface Builder. Can you please help?

My file has the following code:

- (IBAction)getUserPassword:(NSScanner *)sender {
    NSCharacterSet *theCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"123456789开发者_如何学Go0abcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+<>?,./:\";'[]\{}| "];
    [userEntered scanCharactersFromSet:theCharacterSet intoString:&temp];
}


It looks like you're trying to connect NSScanner like a UI object. NSScanner isn't a UI object. Did you mean this instead?

- (IBAction)getUserPassword:(UITextField *)textField {
    NSScanner *userEntered = [NSScanner scannerWithString:textField.text];
    NSString *temp = nil;
    NSCharacterSet *theCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"1234567890abcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+<>?,./:\";'[]\{}| "];
    [userEntered scanCharactersFromSet:theCharacterSet intoString:&temp];
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜