• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: BOOL array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BOOL array


  • Subject: Re: BOOL array
  • From: Alex Reynolds <email@hidden>
  • Date: Mon, 15 Sep 2008 15:16:53 -0700

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@hidden> 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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: BOOL array
      • From: Ken Thomases <email@hidden>
References: 
 >Re: BOOL array (From: "Alex Reynolds" <email@hidden>)
 >Re: BOOL array (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: Core Data and ordered relationships
  • Next by Date: Re: NameAndPassword Sample Code
  • Previous by thread: Re: BOOL array
  • Next by thread: Re: BOOL array
  • Index(es):
    • Date
    • Thread