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 1043481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:40:22+00:00 2026-05-16T15:40:22+00:00

I have created a subclass for a UIButton and was hoping to pass a

  • 0

I have created a subclass for a UIButton and was hoping to pass a custom property to it. However, it’s not working and I’ve since read that subclassing a UIButton isn’t a great idea.

MY question is how do I assign a custom property to a button? I am creating a button which is being placed in the headerview of a grouped table. I want to pass to that button the section number. I’ve done this successfully with a UISwitch in each row, but can’t use the same method for the UIButton.

So I create a button

MattsButtonClass *button = [MattsButtonClass buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(240, 15, 45, 30);
button.MFsectionNo = section; //this would be 1, 2 etc
//etc

So how do I actually do this? you’ll see that my UIbutton has a subclass, which looks like this

//.h file
@interface MattsButtonClass : UIButton {
    int MFsectionNo;
}

@property (nonatomic) int MFsectionNo;

@end

//.m file
@implementation MattsButtonClass

@synthesize MFsectionNo;


@end

The error on the above is

-[UIRoundedRectButton MFsectionNo:]: unrecognized selector sent to instance 0x5673650
2010-09-07 22:41:39.751 demo4[67445:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIRoundedRectButton MFsectionNo:]: unrecognized selector sent to instance 0x5673650'

Is what I am trying not possible? Thanks for any help…

  • 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-16T15:40:23+00:00Added an answer on May 16, 2026 at 3:40 pm

    You could probably just use the tag property of UIButton to store your section number (maybe with an offset, since tag is 0 by default)

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

Sidebar

Related Questions

I have created a subclass of UITableViewController that is used as the custom class
I have created a custom UIButton (UIButton subclass) for my application. Within this button's
I have created a subclass of QGLwidget and I was hoping that I could
I have created a custom UserControl and then another control that is a subclass
I have created a custom subclass of UIView for an interface element that I
I have created a custom subclass of UITableViewCell. There, I allow the user to
I am looking to create a Custom UIButton (not subclass) progrmatically, I would like
I have created a subclass of a generic list so that I could implement
I have created a subclass of the TextBox class so that I can capture
So I have: created a couple of custom controllers (add file UIViewController subclass) in

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.