问题描述:

I am trying to figure out how to use bools in objective c. when i use them though they occasionally give a warning. Here is the code i have

NSString *userUserName = userNameTextField.text;

bool *userNameIsGood = false;

if (userNameTextField.text.length > 0){

userNameIsGood = true; // warning is only on this line

}

else {

userNameIsGood = false;

}

the warning i get is: "Incompatible integer to pointer conversion assigning to 'bool *' from 'int'

thank you

网友答案:

try replace

bool *userNameIsGood = false;

to

bool userNameIsGood = false;

or

bool *userNameIsGood;

if (userNameTextField.text.length > 0){
    *userNameIsGood = true;  // warning is only on this line
}
else {
    *userNameIsGood = false;
}
相关阅读:
Top