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
David Karlsson
  • 9,396
  • 9
  • 58
  • 103

1 Answers1

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.

newacct
  • 119,665
  • 29
  • 163
  • 224
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382