6,最关键的地方,在需要调用C++类的地方,使用@class Hello,而不是#import 或者#include
#import <UIKit/UIKit.h>
//#include "Hello.h"
@class Hello;
@interface ViewController : UIViewController{
}
-(void)aaaa;
@end
7,实现调用C++类中的方法
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"dddddddd");
Hello *aa = [[Hello alloc]init];
[aa sayHellooooo];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
-(void)aaaa{}
@end
8,源代码:Objective-C调用C++
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2013年资料/3月/31日/Objective-C调用C++代码
