Limit textfield character length

Discussion in 'Mac Programming' started by abcdefg12345, Dec 18, 2013.

  1. abcdefg12345 macrumors regular

    abcdefg12345

    Joined:
    Jul 10, 2013
    #1
    I'm trying to limit character length in an app but i have no idea what I'm doing so i made a sample calculator app if anyone can add a code to it that limit how many characters u can inter in the field.
     

    Attached Files:

  2. LinusR macrumors regular

    LinusR

    Joined:
    Jan 3, 2011
    #2
    You can create a delegate referring to the specific NSTextField and overwrite the method
    Code:
    textShouldBeginEditing:
    . It returns a bool, so you can either allow or disallow entering letters depending on how many characters have already been entered.
     

Share This Page