现在的位置: 首页 > 综合 > 正文

Objective-c调用c++文件

2018年01月10日 ⁄ 综合 ⁄ 共 445字 ⁄ 字号 评论关闭

参考文章:http://www.cnblogs.com/cpcpc/archive/2012/08/21/2649264.html,但是发现同样的方法在xcode 4.6已经不行了,实例化对象时会报:

“Receiver type for instance messages is a forward declaration”的错误。即使将"@class Hello;" 改为#import "Hello.h"也还是会在NewHello上报"Unkwon
type class,did you mean Class" 的错误。

于是上stackoverflow里提了个问题http://t.cn/zTwZmWX,没想到还真有人回答了。解决方法是:

The solution is to add

#import "Hello.h" 

to your ViewController.m file and change the file type of ViewController.m to Obj-C++ (from the right panel)

折腾半天的问题到此终于解决。




抱歉!评论已关闭.