1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Problems with Objective-C++?

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

  1. macrumors newbie

    #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

    #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

    #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

    #4
    What a smurftastic solution!
     
  5. macrumors 603

  6. macrumors 6502a

    Sayer

    #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