getting the value of an NSSecureTextField

Discussion in 'Mac Programming' started by liptonlover, Oct 1, 2008.

  1. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #1
    I have a secure text field for a password, and it works fine because I haven't done anything to it. But when I try using the following line of code,
    [getPassword setStringValue:password];
    The rest of the code in the method doesn't get called. Additionally, getPassword still doesn't equal the password. How do I retrieve the password? I've looked at the class documents and securetextfield doesn't seem to have any protection, it doesn't add anything to a regular textfield except that you can't see the typing. Help would be appreciated.
    Thanks, Nate
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    There was another recent thread with NSSecureTextField not working as expected, but from what I can, it is working fine (I made a sample project and tested it). I'm not sure what else to say, just make sure you're using the standard setStringValue: and stringValue methods on the text field, which it looks like you are doing.
     
  3. liptonlover thread starter macrumors 6502a

    Joined:
    Mar 13, 2008
    #3
    I tried changing it to
    Code:
    [thePassword setValue:[password stringValue]];
    
    But it still didn't work. Oh yeah... thePassword is just an NSString, properly alloc'd and init'd. Here's what the console says each time I get to this line, even when I make changes like the above one.
    Code:
    [Session started at 2008-10-01 15:16:28 -0400.]
    2008-10-01 15:16:35.506 Finder[5232:10b] *** -[NSCFString setValue:]: unrecognized selector sent to instance 0xa0721328
    2008-10-01 15:16:35.507 Finder[5232:10b] *** -[NSCFString setValue:]: unrecognized selector sent to instance 0xa0721328
    
    The Debugger has exited with status 0.
    
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    NSString doesn't have a setValue: method. Unless you're using an NSMutableString you can't change a string's value. Reassign it like so:
    Code:
    thePassword = [password stringValue];
     
  5. liptonlover thread starter macrumors 6502a

    Joined:
    Mar 13, 2008
    #5
    thanks... problem solved. I always forget about mutable/immutable classes <_<
    Nate
     

Share This Page