2013-04-22 37 views
1

所以我想从我的viewController.h和.mm移动一些C++对象到我的appDelegate.h和.mm。问题是我得到一个预处理器问题,说明例如找不到,也不能串。我已经尝试将文件类型更改为Objective-C++头文件,但如果我尝试在viewController.h中包含#include,则仍然会出现错误,但不会出现此类错误。我怎样才能在appDelegate中导入C++?包括<iostream>在ViewController.h工作,但不在appDelegate.h

// AppDelegate.h 

#import <UIKit/UIKit.h> 
#include <iostream> // <-"'iostream' file not found" 


@interface AppDelegate : UIResponder <UIApplicationDelegate> 

@property (strong, nonatomic) UIWindow *window; 

@end 

而且工作情况与的viewController:

// ViewController.h 

#import <UIKit/UIKit.h> 
#include <iostream> 


@interface ViewController : UIViewController 

@end 

回答

1

“AppDelegate.h” 也包括来自 “main.m文件”。将该文件重命名为“main.mm”应该解决 的问题。

如果没有必需的公共接口“的iostream”“AppDelegate.h”你应该 或者考虑包括文件只在实现文件“AppDelegate.mm”, 这也将解决这个问题。

+0

@newacct:感谢您解决我的C++错误! – 2013-04-22 09:36:03