Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sure -- you can do this. The main thing that's required is to set the .CPP file as "Objective-C++ Source" -- the ".mm" convention is an automagic nicety, but not required. You can then mix and match pretty much as you please:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #include &lt;iostream&gt; @interface iCloudUtil : NSObject @property(nonatomic, assign, getter=isAvailable) BOOL iCloudIsAvailable; @property(assign) NSString *urlToFile; - (bool) init_iCloud; - (void) loadDocument:(NSString*)fileUrl; @end ////////////////////////////////////////////////////// @implementation iCloudUtil @synthesize urlToFile = _urlToFile; @synthesize iCloudIsAvailable = _iCloudIsAvailable; - (bool) init_iCloud { NSLog(@"init_iCloud"); std::cout &lt;&lt; "i can mix std c++ in here as well\n"; return YES; } - (void) loadDocument:(NSString*)fileUrl { NSLog(@"url is %@",fileUrl); } @end ////////////////////////////////////////////////////// class ICloudInterface { static ICloudInterface* _instance; bool iCloudIsAvailable; iCloudUtil* myCloudUtil; public: ICloudInterface(); ~ICloudInterface(); bool init_iCloud(); }; ICloudInterface::ICloudInterface() { std::cout &lt;&lt; "ICloudInterface::ctor\n"; myCloudUtil = [[iCloudUtil alloc] init]; [myCloudUtil init_iCloud]; [myCloudUtil loadDocument:@"file://foo/bar/baz"]; } ICloudInterface::~ICloudInterface() { [myCloudUtil release], myCloudUtil = nil; std::cout &lt;&lt; "ICloudInterface::dtor\n"; } int main(int argc, const char * argv[]) { std::cout &lt;&lt; "Test objc/objc++\n"; ICloudInterface iface; return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload