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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:48:01+00:00 2026-06-14T22:48:01+00:00

OK I know that this subject has been mentioned many times before on SO,

  • 0

OK I know that this subject has been mentioned many times before on SO, but after checking several such questions, none have talked about the issue I am having with regards to overriding the base class getters/setters in a subclass.

My base class is:

#import <Foundation/Foundation.h>
@interface BaseClass : NSObject
@property (nonatomic, assign) int value;
@end

@implementation BaseClass
@synthesize value;
@end

From that I want the subclass to act as a shim and map the “value” from an int to an enum in my child class:

#import <UIKit/UIKit.h>
#import "BaseClass.h"

typedef enum {
    zero = 0,
    one,
    two,
    three,
    four
} NumberEnum;

@interface ChildClass : BaseClass
-(void)setValue:(NumberEnum)newValue;
-(NumberEnum)value;
@end

@implementation ChildClass

-(void)setValue:(NumberEnum)newValue
{
    [super setValue:(int)newValue];
    NSLog(@"Child Setter");
}

-(NumberEnum)value
{
    NSLog(@"Child Getter");
    return (NumberEnum)[super value];
}

@end

And I test this code using:

ChildClass* fred = [[ChildClass alloc] init];
NumberEnum barney;
fred.value = one;
barney = fred.value;
barney = [fred value];

XCode (4.5.2) generates the warning

Type of property ‘value’ does not match type of accessor ‘value’

On this line only:

barney = fred.value;

When the code is run, I see the log messages for both the Child Setter and Getter. So what should I be doing to eliminate this warning, and why am I getting it in the first place?

  • 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-14T22:48:02+00:00Added an answer on June 14, 2026 at 10:48 pm

    The offending line:

    barney = fred.value;
    

    tells the compiler you want to use the property value. As your child class doesn’t define it, it goes up to the base class. It found value with a different type causing the warning.

    A solution is to write your property as:

    @property (nonatomic, assign) int value;
    

    and the enum as:

    enum {
        zero = 0,
        one,
        two,
        three,
        four
    };
    typedef int NumberEnum;
    

    This way synthesized property methods and your own implementations are working with the same data type. You can use symbolic values and there is no warning.

    I suggest using NSUInteger instead, as it is 64-bits friendly.

    And of course, much better if you just define the property as NumberEnum in the base class.

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

Sidebar

Related Questions

I know that this subject has been seen many times here, but I didn't
First, I know this question has been asked several times before and that in
I know that this sort of question has been asked here before, but still
I know this question has been asked many times, but I am having trouble
I know this subject has been discussed here a bunch of times already. But
I know this question has been asked in several variations before, but my question
I know this question has been asked several times, however, after digging through question
I know that this question had already been asked a couple of times before,
I know that this has already been asked here but the answer (using a
I know this subject has been done already over and over. but... i must

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.