Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 744
Sébastien Avatar asked Jan 27 '16 09:01

Sébastien


2 Answers

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

@implementation MyClass {
    NSMutableArray* _myArray;
}
@end
like image 106
vadian Avatar answered Nov 09 '22 17:11

vadian


@implementation MyClass: NSObject

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

like image 31
Ilan Kutsman Avatar answered Nov 09 '22 18:11

Ilan Kutsman