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

后端 未结 4 1195
猫巷女王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:22

    You must:

    1. Inherit from NSObject,
    2. Do a "poor man's" class with your own mallocs, etc, or
    3. Use Objective-C++ and create a C++ class.

    Of course, neither of the other two fit into Objective-C storage management, and their call protocols, etc, are different.

提交回复
热议问题