objective c - change fieldtext string to * like a password

126 Views Asked by At

I'm working with cocos2D & Spritebuilder while I'm trying to figure out how to make a password CCTextField but I would like some help to change the string into * for every symbol,letter or number you fill in the CCTextField.

Currently I have the following:

AccountVariables.h

#ifndef ProjectName_AccountVariables_h
#define ProjectName_AccountVariables_h

BOOL passwordCheck;

NSString *password;

#endif

Details.h

{
CCLabelTTF *showWarning;

CCTextField *passwordField;
}

Details.m

-(void)didLoadFromCCB
{
passwordField.string = password;
showWarning.string = [NSString stringWithFormat:@""];
}


-(void)passwordField:(CCTextField*)passwordF
{
password = passwordF.string;
[self checkAll];
}


-(void)checkAll;
{
if (password.length == 0)
    {
        showWarning.string = [NSString stringWithFormat:@"Please fill it in"];
        passwordCheck = false;
    }
    else if (password.length < 6)
    {
        showWarning.string = [NSString stringWithFormat:@"it is too short!"];
        passwordCheck = false;
    }
    else if (password.length > 16)
    {
        showWarning.string = [NSString stringWithFormat:@"it is too long!"];
        passwordCheck = false;
    }
    else
    {
        passwordCheck = true;
    }
}
1

There are 1 best solutions below

0
On

The CCTextFiedld hold a reference to the UITextfield object. The property is called:

@property (nonatomic, readonly) UITextField *textField

Get the instance of the UITextField object and set secureTextEntry property to YES.