Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SuperZeroIce

macrumors newbie
Original poster
Jun 5, 2010
13
0
I'm constantly getting a warning from the compiler when initializing a subclass:
Incompatible Objective-C types initializing 'struct Module *', expected 'struct Relais *'

It happens when the following line is called:

Code:
Relais *object = [[Relais alloc] initWithIdentifier:identifier description:description];

There's probably a very simple solution, but this is my second day of learning ObjC. And coming from the wonderful world of Java, I'm having a hard time figuring this one out :D

Module.h:
Code:
#import <Foundation/Foundation.h>


@interface Module : NSObject {
	NSString *identifier;
	NSString *description;
	
}

-(Module *) initWithIdentifier: (NSString *) pIdentifier description: (NSString *) pDescription; 


-(void) setIdentifier: (NSString *) pIdentifier;
-(void) setDescription: (NSString *) pDescription;

-(NSString *) identifier;
-(NSString *) description;

@end

Module.m:
Code:
#import "Module.h"


@implementation Module


-(Module *) initWithIdentifier: (NSString *) pIdentifier description: (NSString *) pDescription
{
	self = [super init];
	
	if (self) {
		[self setIdentifier:pIdentifier];
		[self setDescription:pDescription];
	}
	
	return self;
}


-(void) setIdentifier: (NSString *) pIdentifier
{
	identifier = pIdentifier;
}

-(void) setDescription: (NSString *) pDescription
{
	description = pDescription;
}


-(NSString *) identifier{
	return identifier;
}

-(NSString *) description{
	return description;
}

@end
Relais.h:
Code:
#import <Foundation/Foundation.h>
#import "Module.h"

@interface Relais : Module {
	BOOL aan;

}

-(Relais *) initWithIdentifier: (NSString *) pIdentifier description: (NSString *) pDescription;


- (void) setAan: (BOOL) pAan;

- (BOOL) aan;


-(NSString *) aanCommando;
-(NSString *) uitCommando;


@end
Relais.m
Code:
#import "Relais.h"


@implementation Relais


-(Relais *) initWithIdentifier: (NSString *) pIdentifier description: (NSString *) pDescription
{
	self = [super init];
	
	if (self) {
		[self setIdentifier:pIdentifier];
		[self setDescription:pDescription];
	}
	
	return self;
}



- (void) setAan: (BOOL) pAan
{
	aan = pAan;
}

- (BOOL) aan
{
	
	return aan;
}


-(NSString *) aanCommando {
	return [identifier stringByAppendingString:@"%I"];
	
}
-(NSString *) uitCommando {
	return [identifier stringByAppendingString:@"%O"];
	
}


@end

Strangely enough the initWithIdentifier method IS called from the subclass 'Relais', and all methods from 'Relais' are indeed accessible :confused: :confused:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.