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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:53:10+00:00 2026-06-11T15:53:10+00:00

I created UILabel category which would do extra work when font property is changed.

  • 0

I created UILabel category which would do extra work when font property is changed.

I have chosen category over sublassing so I do not have to change class for all labels in my all XIB files. I just add this category declaration to the prefix header and category is visible in the whole project scope.

Implementation file:

//
//  UILabel+XIBCustomFonts.m


#import "UILabel+XIBCustomFonts.h"

@implementation UILabel (XIBCustomFonts)
BOOL comes_from_nib = NO;


-(id)initWithCoder:(NSCoder *)aDecoder_{

    self = [super initWithCoder:aDecoder_];

    if (self) {
        comes_from_nib = YES;

    }
    return self;
}

-(void)setFont:(UIFont *)font_{

    [super setFont:font_];
    NSLog(@"Setting from for label from XIB for name:%@ size: %.1f - do font theme replacement if needed", self.font.fontName, self.font.pointSize);

}
@end

The surprising thing is the crash with following log:

-[UIButtonLabel setFont:]: unrecognized selector sent to instance 0x9ad1b70
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButtonLabel setFont:]: unrecognized selector sent to instance 0x9ad1b70'

Where did UIButtonLabel came form?

It happens even if I do extra Class checking in setFont: setter:

if ([self class] != [UILabel class] || !comes_from_nib) {

        [super setFont:font_];
        return;

    }

Is there any way to override setFont: setter in UILabel without subclassing?

  • 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-06-11T15:53:11+00:00Added an answer on June 11, 2026 at 3:53 pm

    You cannot call super methods in categories! Never!
    This is not possible when you use a category to augment a class’ functionality, you are not extending the class, you are actually wholly overriding the existing method, you lose the original method completely. That’s why your error appears.

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

Sidebar

Related Questions

I have created a MultilineCell for my app, which shows first a UILabel consisting
Sorry, a beginner's questions: I have created an instance of an UILabel and would
In Xcode, I created a UILabel which will autoresize depending on how many lines
I have a custom cell which has two UILabel objects. //AppEventCell.h #import <UIKit/UIKit.h> @interface
I have a code in which all UI items created by dynamically. I have
I have created a custom view cell with a UILabel in it, I have
I created custom UITableViewCell. @interface AnswerCell : UITableViewCell @property (nonatomic, retain) IBOutlet UILabel *textLabel;
Ok, so I have a UILabel created in interface builder that displays some some
I have a great problem, I have a UILabel created programmatically and then connect
I have created one application in which if i select on particular row 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.