Search code examples
objective-cc-preprocessorconditional-compilationpreprocessor-directive

an someone please explain to me what #ifdef does here?


Can someone please explain what #ifdef..#else..#endif does in this piece of code? It's from an open-source iphone twitter client.

#ifdef ENABLE_OAUTH
@interface NTLNTwitterClient : NTLNOAuthHttpClient {
#else
@interface NTLNTwitterClient : NTLNHttpClient {
#endif
    int requestPage;
    NSString *screenNameForUserTimeline;
    BOOL parseResultXML;
    NSObject<NTLNTwitterClientDelegate> *delegate;
    BOOL requestForTimeline;
    BOOL requestForDirectMessage;
    NTLNTwitterXMLParser *xmlParser;
}

Solution

  • If ENABLE_OAUTH is defined somewhere else, then the class NTLNTwitterClient will be a subclass of NTLNOAuthHttpClient.

    If ENABLE_OAUTH is not defined, then the class NTLNTwitterClient will be a subclass of NTLNHttpClient.