Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4248282
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:13:55+00:00 2026-05-21T04:13:55+00:00

I need to add two additional properties (NSString * and NSMutableArray *) along with

  • 0

I need to add two additional properties (NSString * and NSMutableArray *) along with three extra methods to UIButton. I also want to reference the new objects using a supertype if that is possible. I do not necessarily want to subclass (as I read that it is tricky and not recommended), but I am quite new to Objective-C and iOS development and don’t know what else to do.

I tried to subclass UIButton with my subclass implementing a formal protocol in the following way:

@interface Button : UIButton <MyProtocol> ...

However, I found out this doesn’t work like I thought it would, as buttonWithType: returns an object from a subclass. What else can I do to achieve the desired result?

— EDIT:
Ok, my current code is like this:

@interface Button : UIButton <SteapeObject> {
    ActionQueue * actions;
    Meta meta;
}

@property (nonatomic, retain) ActionQueue * actions;
@property (nonatomic) Meta meta;

- (id) initWithFrame:(CGRect)frame;
...

And the implementation:

- (id) initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        NSLog (@"finally");
    }

    return self;
}

An still doesn’t work. It seems that when I invoke:

Button * button = [Button buttonWithType: UIButtonTypeRoundedRect];
NSLog (@"%@", [button description]);

I should get two ‘finally’ strings and two descriptions in the log. However, I only get the two description strings:

[Session started at 2011-02-24 09:47:14 +0100.]
2011-02-24 09:47:15.431 IphoneClient3[702:207] <UIRoundedRectButton: 0x5f47690; frame = (0 0; 0 0); opaque = NO; layer = <CALayer: 0x5f47240>>
2011-02-24 09:47:15.461 IphoneClient3[702:207] <UIRoundedRectButton: 0x6a0f000; frame = (0 0; 0 0); opaque = NO; layer = <CALayer: 0x6a344b0>>

And you can see that the type is still UIRoundedRectButton, but the buttons do not respond to my added methods. Actually, since my overriden initWithFrame doesn’t get called, that is to be expected. Perhaps I should default to implementing a custom control…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:13:55+00:00Added an answer on May 21, 2026 at 4:13 am

    I found that it is not possible to accomplish that task with the current implementation of the SDK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP's DateTime class has the two methods add() and sub() to add or subtract
I have a method what accepts two parameters and now I need to pass
I need to store some Photo related information for my app. I understand that
I have a two separate tables that contain parts of user name (don't ask
I have two applications: X and Y. X is the main application and it
I'm trying to visualize Mandelbrot set with OpenGL and have found very strange behaviour
Preamble: Don't be scared off by the fact My Rails 3 app uses the
I've seen a lot of advice about Git workflow, but it wasn't extremely usable
Got a slightly tricky problem I'd like some advice on. I have a source
I have a situation where Project can have many Tags (and vice versa), so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.