从C ++类继承NSObject [英] Inherit NSObject from C++ class

查看:116
本文介绍了从C ++类继承NSObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对C ++类非常着迷,但我真的希望它进入表格视图.

I'm emotionally attached to my C++ class, but I really want it to go into a tableview.

是否可以从标准c ++类继承NSObject?

Is there a way to subclass NSObject from a standard c++ class?

这是我试图做的事情

class Model : NSObject {
public:
    NSString *key;
};

编译器一点都不喜欢它.

The compiler did not like it one bit.

它告诉我基本说明符必须是一个类.

It tells me the the base specifier must be a class.

我能做些偷偷摸摸的事吗?

Is there any kind of sneaky thing I can do?

我应该使它成为标准的目标C ++对象吗?

Should I just make it a standard objective C++ object?

推荐答案

您不能在C ++和Objective-C类之间混合继承.

You cannot mix inheritance between C++ and Objective-C classes.

相反,只需制作一个标准的Objective-C ++对象即可,它包装了您的C ++对象.教Obj-C对象如何将所有内容传递给C ++对象.

Instead, just make a standard Objective-C++ object which wraps your C++ object. Teach the Obj-C object how to pass everything through to your C++ object.

这篇关于从C ++类继承NSObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆