Problems with Objective-C++?

Discussion in 'Mac Programming' started by frank100, Aug 6, 2012.

  1. frank100
    Expand Collapse
    macrumors newbie

    May 9, 2012
    Every so often I have my rants with Objective-C because I terribly miss having namespaces and templates, something that seems already solved in Objective-C++

    Although it seems an easy transition, I am not sure about the problems of switching to Objective-C++

    So far I have read about problems with ARC, interface builder, refactoring and instruments tools... but I am not sure if all that is "still true"

    How safe is it switching to Objective-C++? Which problems should I expect? In which cases should I avoid it? Should I avoid Objective-C++ in my views and/or setting that as the main class of my XIBs?
  2. gnasher729
    Expand Collapse
    macrumors G5


    Nov 25, 2005
    Do yourself a favor and enjoy life without namespaces and templates. Objective-C++ is for connecting Objective-C with C++ code and nothing else. Objective-C classes don't use namespaces. And they don't use templates.
  3. Mac_Max
    Expand Collapse
    macrumors 6502

    Mar 8, 2004
    I miss namespaces as well. I hope that at some point they're added as an optional extension to Obj C. In the meanwhile you can use smurf naming to avoid problems... I.e.


    If you aren't familiar with the smurfs.... Basically prefix every class name.

    If you're working with something that can be done dramatically faster with templates then do just that part with a template method or a template function (remember that not all things need to be done with objects).
  4. iMacFarlane
    Expand Collapse
    macrumors 65816


    Apr 5, 2012
    Phaselocking Psychos somewhere on Pandora
    What a smurftastic solution!
  5. Sayer
    Expand Collapse
    macrumors 6502a


    Jan 4, 2002
    Austin, TX
    This guy has a lot of insight into writing Objective-C code better than you may be doing it now.

    Instead of trying to force Objective-C to be like [some other language] just try to write Objective-C code the Objective-C way, or the Objective-C 2.0 way.

Share This Page