1
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// getting the string
iapstring = [prefs stringForKey:@"stringVal"];

if (iapstring == nil) {
    //Action
}

if (iapstring !== nil) {
    //Action
}

The problem is in the 2nd if I get exptected expression before = token

Is this the right or wrong way to do it?

Rick
  • 83
  • 6
  • 2
    You've asked 7 questions and you haven't accepted answers for any of them. This is probably hurting your ability to get an answer to this one. – Arkaaito Feb 22 '11 at 07:12

1 Answers1

1

In C, the opposite of == is != (not !==). So you want if (iapstring != nil).

However, in Objective-C, nil is just (id)0, a false value. So you can safely use if (iapstring) to test that iapstring has an assigned value.

kevingessner
  • 18,559
  • 5
  • 43
  • 63