PDA

View Full Version : Problems with Objective-C++?




frank100
Aug 7, 2012, 01:30 AM
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?



gnasher729
Aug 7, 2012, 03:08 AM
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++?

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.

Mac_Max
Aug 8, 2012, 02:16 AM
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).

iMacFarlane
Aug 8, 2012, 11:00 AM
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).

What a smurftastic solution!

chown33
Aug 8, 2012, 11:34 AM
There's more to it than smurfing:
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html

Sayer
Aug 8, 2012, 04:49 PM
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.