我有这样哪里定义我所有的常量/全局变量?
#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
,然后试图在我的ViewController定义我的HttpClient作为
httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://www.test.com/"]];
它给了我一个错误说use of undeclared identifier 'httpClient'
也看看YourApp-Prefix.pch,这是所有的源文件 – Thorsten 2013-03-09 09:30:50
@Thorsten头可以请您详细阐述多一点?这将如何工作? – Jonathan 2013-03-09 09:37:56
你想在所有文件中都有相同的'httpClient'实例,或者每个文件都有一个新的不同实例吗? – Hejazi 2013-03-09 09:42:10