ios - Assigning Property to Loaded .xib -


i'm attempting alter title of button in .xib i'm loading as:

customtoolbar *toolbar = (customtoolbar *)[[[[nsbundle mainbundle]                                            loadnibnamed:@"coolbar"                                            owner:self options:nil] objectatindex:0]                                            initwithframe:cgrectmake(0, self.view.frame.size.height, self.view.frame.size.width, 70)]; 

i've tried changing directly using

toolbar.button.titlelabel.text = @"value"; 

and through custom setter method,

- (void)updatebuttontext:(nsstring *)buttontext {     _button.titlelabel.text = buttontext; } 

however, defaults value given in .xib file.

customtoolbar *toolbar =      (customtoolbar *)[[[[nsbundle mainbundle]          loadnibnamed:@"coolbar"          owner:self options:nil] objectatindex:0]      initwithframe:cgrectmake(         0, self.view.frame.size.height, self.view.frame.size.width, 70)]; 

your code makes no sense. cannot / must not init object loaded nib; has been initialized.

i suggest take statement apart several steps , make sure each step giving result expect - , abandon init, of course.

nsarray* arr = [nsbundle mainbundle]          loadnibnamed:@"coolbar"          owner:nil options:nil]; // did load? id obj = [arr objectatindex: 0]; // did customtoolbar? customtoolbar *toolbar =      (customtoolbar *) obj; // still ok? toolbar.frame = cgrectmake(     0, self.view.frame.size.height, self.view.frame.size.width, 70); 

and on.

then can start think want do toolbar. @ moment not being put interface, have no way of knowing whether changes affecting or not. once is, can start asking rest of code. example, insane (and wrong) try set uibutton's titlelabel.text directly; not how button works. once have toolbar, can say

[toolbar.button settitle:@"value" forstate: uicontrolstatenormal];