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 you should use the designated initializer of the given class. The blog entry doesn't include the full interface of the class, so I don't know exactly what the designated initializer is, but given that it's a UIButton subclass, and UIButtons are instantiated from a class method, I would expect that it needs to be instantiated from a class method also, like this:

CustomButton*myButton = [CustomButton buttonWithType:UIButtonTypeRoundedRect];

Luke


On Aug 15, 2009, at 5:07 AM, Agha Khan wrote:

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 exception at this point.

I know the reason I do not have a nib file, but I believe I don't need it.

According to author
The initWithCoder: method is what will be called when the game reads the button in from the nib files.

But I do not have any nib file in my project. What can we do in such situation?


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to