J'ai des choses commeOù définir toutes mes constantes/variables globales?
#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];
que je dois définir dans tous mes fichiers tout le temps. Est-il possible de les définir dans un fichier et de les importer à chaque fois?
modifier
Donc, comme suggéré j'ai ajouté ceci dans mon délégué app
#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
puis essayé de définir mon httpClient dans mon viewcontroller comme
httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://www.test.com/"]];
il me donne une erreur disant use of undeclared identifier 'httpClient'
Jetez aussi un coup d'œil à YourApp-Prefix.pch, qui est un en-tête pour tous les fichiers source – Thorsten
@Thorsten pouvez-vous s'il vous plaît expliquer un peu plus? Comment cela fonctionnerait-il? – Jonathan
Voulez-vous avoir la même instance 'httpClient' dans tous les fichiers, ou une nouvelle instance différente pour chaque fichier? – Hejazi