BOOL vs. bool aside (as well as a couple methods that return NSString* and throw NSException) I wanted to take a stab at making this particular class more portable.

If I wrote it closer to the C++ STL spec, I could more easily use it in other contexts while writing my larger application in Cocoa (well, Cocoa Touch, but I guess I can't really say that).

I also wanted to learn a bit about Objective-C++.

What are the issues that involve exceptions? I find that NSExceptions I have in my larger application still work when I poke those.

I did set up something like:

--------------------------
#include <exception>

...
try {
std::vector<BOOL> *myTestVector = new std::vector<BOOL>(numOfElements, emptyElement);
} catch(std::bad_alloc &exc) {
        NSLog(@"%@", exc.what());
}
...
delete myTestVector;
--------------------------

but I haven't pressure tested it with, say, 100 million elements to see if it cracks.

I do run into lots of compilation errors if I don't rename all of my Cocoa classes to *.mm. But otherwise, the application compiles fine and I seem to be able to use all the ObjC syntax I'm used to.

I apologize if these are dumb questions. I appreciate all the advice.

-Alex

Kyle Sluder wrote:
On Mon, Sep 15, 2008 at 5:43 PM, Alex Reynolds <[EMAIL PROTECTED]> wrote:
Are there any downsides to creating Cocoa-based applications in Objective
C++?

If you're switching to Objective-C++ just to get std::vector, I would
strongly suggest you reconsider.  There are plenty of issues regarding
ObjC++ in the legacy runtime, particularly involving exceptions.  Is
there a reason you chose to make such a radical change instead of just
using CFBitVector?

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to