开发者

Problem with NSScanner in the IB connections

开发者 https://www.devze.com 2023-02-28 21:46 出处:网络
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 Build

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

精彩评论

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