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
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
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
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
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
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
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