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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:20:10+00:00 2026-06-03T03:20:10+00:00

Okay. Tough to find the best starting point, here. The error XCode (4.3.2) in

  • 0

Okay. Tough to find the best starting point, here. The error XCode (4.3.2) in Lion is kicking back to me is:

Redefinition of 'a' with a different type

The author says when we declare this line (near the bottom of this page, in main)…

OwnedAppliance *a = [[OwnedAppliance alloc] init];

…that it should run fine. It doesn’t. It kicks back the error above. I understand that, because OwnedAppliance has no init method in its implementation, the compiler will go up the hierarchy to OwnedAppliance’s superclass, which is Appliance, and search for an init method there. It finds the overridden init, which contains only the following line…

[self initWithProductName:@"Unknown"];

…and runs that. Understood.

Ugh. Sorry, guys. I just tried to explain what I think might be happening. It took a dozen lines and I’d just scratched the surface. Rather than bore you with what I think is happening, I’ll just ask:

What’s going on with this code? Where does the initialization “path”, for lack of a better term, end? Where does the redefinition (the error) occur?

/********************  Appliance.h  ********************/

#import <Foundation/Foundation.h>

@interface Appliance : NSObject
{
    NSString *productName;
    int voltage;
}

@property (copy) NSString *productName;
@property int voltage;

-(id)init;
// Designated initializer
-(id)initWithProductName:(NSString *)pn;
...
@end

/********************  Appliance.m  ********************/

#import "Appliance.h"

@implementation Appliance

@synthesize productName, voltage;

-(id)init
{
    return [self initWithProductName:@"Unknown"];
}

-(id)initWithProductName:(NSString *)pn
{
    self = [super init];

    if (self) {    
    [self setProductName: pn];
    [self setVoltage: 120];
    }

    return self;
...

@end

/********************  OwnedAppliance.h  ********************/

#import "Appliance.h"

@interface OwnedAppliance : Appliance
{
    NSMutableSet *ownerNames;
}

// Designated initializer
-(id)initWithProductName:(NSString *)pn
          firstOwnerName:(NSString *)n;
...

@end

/********************  OwnedAppliance.m  ********************/

#import "OwnedAppliance.h"

@implementation OwnedAppliance

-(id)initWithProductName:(NSString *)pn
          firstOwnerName:(NSString *)n
{
    self = [super initWithProductName:pn];

    if (self) {
        ownerNames = [[NSMutableSet alloc] init];

    if (n) {
        [ownerNames addObject:n];
        }
    }
    return self;
}

-(id)initWithProductName:(NSString *)pn
{
    return [self initWithProductName:pn
                      firstOwnerName:nil];
}
...
@end

/********************  main.m  ********************/

#import <Foundation/Foundation.h>
#import "Appliance.h"
#import "OwnedAppliance.h"

int main(int argc, const char * argv[])
{
    @autoreleasepool {
    //  Previously omitted problematic code:
        Appliance *a = [[Appliance alloc] init];
        NSLog(@"a is %@", a);
        [a setProductName:@"Washing Machine"];
        [a setVoltage:240];
        NSLog(@"a is %@", a);

    //  The following line is where the error occurs:
        OwnedAppliance *a = [[OwnedAppliance alloc] init];
        ...
    }
    return 0;
}

I’ve thought a lot about this question and how to ask it. I don’t think it’s a terribly dumb one. 🙂 But my brain is fried from 9 hours of studying this stuff, so I apologize if this is a totally obvious question. TIA

EDIT: main() now contains the code that was actually causing the error. Thanks to Jacques for being good enough to catch it despite the omission.

  • 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-03T03:20:12+00:00Added an answer on June 3, 2026 at 3:20 am

    The compiler’s actually telling you that the variable itself, a, has been declared twice; the error has nothing to do with the assignment. Somehwhere else, in scope, you have another variable named a, which has a different type than OwnedAppliance *. Change the name(s) of one (or both) and the error will go away.

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

Sidebar

Related Questions

Okay, this is probably a very basic question; but, I'm just getting back in
Okay, I have GOT to be missing something totally rudimentary here. I have an
Okay, so this is a tough one, I've spent hours looking for a solution/problem.
I'm getting an undefined symbol error even though I think I've defined it okay.
Okay, next PHPExcel question. I have an HTML form that users fill out and
Okay this question is very simple: I have a facebook page, and a website.
Okay, I feel a bit foolish for having to ask this but I guess
Okay, I have the following create action #posts_controller, nested resource under discussions def create
Okay, so I have my post.php page. If you are not logged in, you'll
Okay, so I'm working on a java server for an Apps backend, it 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.