Sébastien
Sébastien

Reputation: 14821

Meaning of warning "Class implementation may not have super class"

I have created a very basic Objective-C class.

MyClass.h

@interface MyClass: NSObject
@end

MyClass.m

#import "MyClass.h"
@interface MyClass()
@end

@implementation MyClass: NSObject  {
    NSMutableArray* _myArray;
}
@end

Xcode is showing the following warning on the @implementation line:

Class implementation may not have super class

The warning goes away if I remove the NSMutableArray* _myArray; line.

What does this warning mean? What am I doing wrong?

Upvotes: 6

Views: 772

Answers (2)

Ilan Kutsman
Ilan Kutsman

Reputation: 469

@implementation MyClass: NSObject

You're not supposed to inherit from NSObject in the implementation. you already got it in the @interface MyClass: NSObject

Upvotes: 2

vadian
vadian

Reputation: 285082

Delete NSObject in the implementation part. The super class has to be specified only in the interface.

@implementation MyClass {
    NSMutableArray* _myArray;
}
@end

Upvotes: 9

Related Questions