initWithCoder but I do not have nib file

2009-08-15 Thread Agha Khan
Hi: I was looking a blog about customButton http://supergravelynbros.com/?p=871 The author explained that initializing with - (id)initWithCoder:(NSCoder *)coder I implemented something like this self.helpButton = [CustomButton initWithCoder:UIButtonTypeRoundedRect]; which complies OK, but get

Re: initWithCoder but I do not have nib file

2009-08-15 Thread Chase Meadors
Looks like you don't quite understand -init/initWithCoder methods. Why are you passing UIButtonTypeRoundedRect as the (NSCoder *)coder argument? -initWithCoder only exists to be called when an object is created in a nib. From the documentation on the NSCoding protocol (which includes in

Re: initWithCoder but I do not have nib file

2009-08-15 Thread Luke the Hiesterman
What? No, that is not the idea. When an object is unarchived from a nib it is instantiated as part of the unarchiving process, and you're supposed to perform initialization in initWithCoder:, not allocation (that's why in Cocoa we separate the concepts of allocation and initialization). The

Re: initWithCoder but I do not have nib file

2009-08-15 Thread Luke the Hiesterman
For some reason I don't have this original email in my inbox, but to the author: As you've observed, initWithCoder: is called when your object is instantiated from a nib. Since you don't have a nib, and you're instantiating the object in code, you should not use initWithCoder:. Instead yo

Re: initWithCoder but I do not have nib file

2009-08-15 Thread Chase Meadors
You're completely correct, that was an error on my part. I don't know exactly why I wrote it that way... morning? On Aug 15, 2009, at 9:55 AM, Luke the Hiesterman wrote: What? No, that is not the idea. When an object is unarchived from a nib it is instantiated as part of the unarchiving proc

Re: initWithCoder but I do not have nib file

2009-08-15 Thread Agha Khan
Thank for reply. First of all I should had written self.helpButton = [UIButton buttonWithType:UIButtonTypeCustom]; Not UIButtonTypeRoundedRect CustomButton*myButton = [CustomButton buttonWithType: UIButtonTypeCustom]; That does not work either, even my base class is UIButton for CustomBut

Re: initWithCoder but I do not have nib file

2009-08-17 Thread Scott Ribe
I think what you want to do is override +buttonWithType in your CustomButton class, but it's not entirely clear from your message. -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (C