简体   繁体   中英

Input value into define method

Get confusing define methods below

#define SELF_PASSWORD @"0"
#define SELF_DROPBOX @"1"
#define SELF_ABOUT @"2"

#define SELF_TABLE_TITLE_PASSWORD @"Password"
#define SELF_TABLE_TITLE_DROPBOX @"Dropbox"
#define SELF_TABLE_TITLE_ABOUT @"About"

#define SELF_TABLE_HEADER_TITLE(SECTION) = SECTION==SELF_PASSWORD?    SELF_TABLE_TITLE_PASSWORD:SECTION==SELF_DROPBOX?SELF_TABLE_TITLE_DROPBOX:SELF_TABLE_TITLE_ABOUT
-(void)buttonActionPassword:(UIButton *){
    NSLog(@“Title : %@”, SELF_TABLE_HEADER_TITLE(SELF_PASSWORD));
}

-(void)buttonActionAbout:(UIButton *){
    NSLog(@“Title : %@”, SELF_TABLE_HEADER_TITLE(SELF_ABOUT));
}

can we use SELF_TABLE_HEADER_TITLE(SELF_PASSWORD) method? Xcode error says 'Expected expression' what is that issue?

Issue fixed,

#define SELF_TABLE_HEADER_TITLE(key) [key isEqual:SELF_PASSWORD]?SELF_TABLE_TITLE_PASSWORD:[key isEqual:SELF_DROPBOX]?SELF_TABLE_TITLE_DROPBOX:SELF_TABLE_TITLE_ABOUT;

" == " is not work. working use isEqual function.

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