1

So I am trying to move some C++ objects from my viewController.h and .mm to my appDelegate.h and .mm. Problem is I get a preprocessor issue stating that for example can not be found, neither can string. I've tried to change file type to Objective-C++ header but still I get an error, if I try to #include in the viewController.h I get no such error. How can i import c++ in the appDelegate?

//  AppDelegate.h

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


@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

And the working case with viewController:

//  ViewController.h

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


@interface ViewController : UIViewController

@end

1 Answer 1

1

"AppDelegate.h" is also included from "main.m". Renaming that file to "main.mm" should solve the problem.

If "iostream" is not required for the public interface "AppDelegate.h" you should alternatively consider to include that file only in the implementation file "AppDelegate.mm", that would also solve the problem.

1
  • @newacct: Thank you for fixing my C++ faux pas!
    – Martin R
    Apr 22, 2013 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.