Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Creating selectors to work around templates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating selectors to work around templates



On Jul 14, 2011, at 5:48 AM, Jonathan Schleifer wrote:

> It seems you misunderstood what ObjC++ is. ObjC++ is two separate langauges in the same file, ObjC and C++. They can't be mixed, because they are incompatible.

You can make them compatible, and we've shipped some projects that used Objective-C++ very successfully to mix C++ and Objective-C code (the C++ being a cross-platform core base, and Objective-C with Cocoa for a native GUI).

This topic has been beaten to death on various other forums and Wikis, so I hardly want to extend the discussion here.  For Kelvin's benefit, there are implementations of C++ smart pointers for Objective-C objects, e.g. see

 http://web.archive.org/web/20051223092340/http://www.top-house.dk/~aae0030/cocoastl/CocoaSTL.h
 http://www.levelofindirection.com/journal/2010/8/13/ocptr-a-smart-pointer-for-objective-c.html

CocoaSTL also includes iterators for Objective-C containers, so that you can use STL algorithms on them.  FWIW, I don't think it's worth it to try to bridge the two languages unless you have a lot of code in C++ that you want to make available in a Mac/iPhone-native app, and then you should have a very limited number of Objective-C++ files around.  Trying to write code to awesomely mix and match the best of both worlds is always fun, but the engineering gains are typically limited.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Creating selectors to work around templates (From: Kelvin Chung <email@hidden>)
 >Re: Creating selectors to work around templates (From: Jonathan Schleifer <email@hidden>)
 >Re: Creating selectors to work around templates (From: Jonathan Schleifer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.