我有类似的东西
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://www.test.com/"]];
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"xyz" accessGroup:nil];
我必须一直在我的所有文件中定义。有没有办法可以在一个文件中定义它们,每次都导入它?
编辑
所以按照建议我将它添加到我的应用程序委托中
#import <UIKit/UIKit.h>
@class AFHTTPClient;
@class KeychainItemWrapper;
@interface TestAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, strong, readonly) AFHTTPClient *httpClient;
@property (nonatomic, strong, readonly) KeychainItemWrapper *keychainItem;
@end
然后尝试在我的视图控制器中将我的 httpClient 定义为
httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://www.test.com/"]];
它给了我一个错误说use of undeclared identifier 'httpClient'