mardi 1 décembre 2015

comparing strings with isEqual isn't running the full function iOS

I have an annoying issue I'm trying to get around but its just not happening so either I'm missing something stupid or I'm doing it wrong.

basically id like to check a string and if its a no, then load blank strings, if its anything else then load the real strings.

here is my code.

 NSString* q1ynu = [defaults objectForKey:@"1aq1ynu"];
if ([q1ynu isEqualToString:@"No"]){
    NSString *q1text = @" ";
    NSString *q1lmh = @" ";
}else{
    NSString* q1lmh = [defaults objectForKey:@"1aq1lmh"];
    NSString* q1text = [defaults objectForKey:@"1aq1"];
}

I'm putting NSString *q1text = @" "; after implementation and before viewDidLoad but it does complain about the unused variable.

It was loading all 3 answers before regardless of the No check but now after playing its loading the first answer of No, or yes and nothing else?

Am i missing something or is this just not supposed to work? if not then what will work because I am at a loss?

Thanks all

Aucun commentaire:

Enregistrer un commentaire