How to instantiate a class in Objective-C that don't inherit from NSObject

后端 未结 4 1196
猫巷女王i
猫巷女王i 2020-12-15 04:38

Given this:

Person.h:

@interface Person 
{
}
- (void) sayHello;
@end

Person.m:

#import \"Person.h\"

@implementa         


        
4条回答
  •  庸人自扰
    2020-12-15 05:19

    you can't..

    Alloc and new ..copy init all these methods are defined in NSObject..

    You cannot also create your own since apple does not provide NSObject implementation class..so you have to inherit from NSObject or its subclass so that you can initialize your class

提交回复
热议问题