简体   繁体   中英

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.

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

似乎您忘记了在应用程序B的constants_new.h文件中导入Foundation类:

#import <Foundation/Foundation.h>

Make sure you import UIKit in your .h file. Add the following line on the top of your .h file

#import <UIKit/UIKit.h>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM