Home > Enterprise >  iOS AppDelegate.mm String literal must be prefixed by '@'
iOS AppDelegate.mm String literal must be prefixed by '@'

Time:09-08

  if (appCenterConfig[@"AppSecret"] != "APPCENTER_SECRET") {
    [AppCenterReactNative register];
    [AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true];
    [AppCenterReactNativeCrashes registerWithAutomaticProcessing];
  }

I got the following error: String literal must be prefixed by '@'.

How can this issue be fixed? I'm a JS developer and not really familiar with iOS world. I guess @ should also be provided somewhere?

Thanks!

CodePudding user response:

Literals, including string literals in Objective-C have to be prefixed with @ because the regular "quoted string" already means something else in C, and Objective-C is a superset of C.

"Thing in quotes" is a C string.

@"Thing in quotes" is a NSString object.

You can't compare NSStrings for equality with == or !=

Use [A isEqualToString:B] for comparing strings

  • Related