Confused Confused - 1 year ago 179
iOS Question

static NSString *const - throws error 'Unknown type name 'NSString'' in iOS

I'm just copied the below line from my existing application's(Say app A) constants header file (Constants.h) to my new app's (Say app B) constants header file (Constants_new.h)

static NSString *const xxx = @"yyy";

This line does not show any error/warning with my app A. But when I copy this line to my app B's constants_new.h file, it throws an error as,

Error: Unknown type name 'NSString'

Please help me to resolve this.

P.S: If I copy the whole file content of constants.h, and paste it to the constants_new.h file, there is no error.

Answer Source

Seems that you forgot to import Foundation classes in your app B's constants_new.h file:

#import <Foundation/Foundation.h>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download