I made the transition from C++ to objective-C a while ago, and am now finding NSLog() tiresome. Instead, still in Objective-C, I would like to be able to write something like
stdout << “The answer is ” << 42 << “\n”;
(I know that NSLog prints to stderr, I could put up with writing stderr << “Hello world”;)
Basically, I just want to be able to use the C++ pipe syntax in Objective-C.
I don’t care about speed (within reason) or if the only method uses precompiler macros or other hack-ish things.
You really should get used to format strings as in
NSLog. The C++ style syntax may be easy to write, but it is a nightmare to maintain. Think about internationalization. A format string can easily be loaded at runtime. Cocoa provides the functionNSLocalizedStringfor that. But for C++’s stream operators you probably have to write different code for every language.