Problems with Objective-C++?

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

  1. macrumors newbie

    Joined:
    May 9, 2012
    #1
    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. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    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. macrumors 6502

    Joined:
    Mar 8, 2004
    #3
    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.

    smurfPartsTableViewController
    smurfTextHelpingClass

    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. macrumors 65816

    iMacFarlane

    Joined:
    Apr 5, 2012
    Location:
    Phaselocking Psychos somewhere on Pandora
    #4
    What a smurftastic solution!
     
  5. macrumors 603

    Joined:
    Aug 9, 2009
  6. macrumors 6502a

    Sayer

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

    http://wilshipley.com/blog/labels/code.html

    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