Object name from String in Objective-C -
i want set name of object uibutton string.
nsstring *buttonname = [[nsstring alloc] initwithstring:@"somestring"];
my goal is:
uibutton *somestring = [[uibutton buttonwithtype:uibuttontypecustom]retain];
how can solve this?
you can't - variable names resolved compiler before objective-c code executed. can maintain map of strings objects buttons etc. using nsmutabledictionary
:
nsstring *string = @"somestring"; [buttonmap setobject: [uibutton buttonwithtype:uibuttontypecustom] forkey: string]; //...time passes... [[buttonmap objectforkey: @"somestring"] setenabled: yes];
Comments
Post a Comment