6 ms·
It’s definitely NOT cross-platform. He’s just calling the objective-c runtime from C.
by tzahola 9y ago
It’s definitely NOT cross-platform. He’s just calling the objective-c runtime from C.
- drb91 9y agoMaybe I'm reading wrong, but I read it more that if the Objective-C interface is small, i.e. the bulk of your app is cross-platform C, you could easily use C to interact with the runtime.
- vlovich123 9y agoSo why not just write the Objective-C part in C rather than calling the underlying machinery directly. It's a neat project to learn the internals, but I wouldn't ever structure a real app this way.
- curyous 9y agoIf you write part of it in C, then you can reuse that code on another platform.
- 0x0 9y agoObjective-C is a superset of C though, so you might as well write the platform specific stuff in an .m file rather than messing around with the .c API for Objective-C. :)
- vlovich123 9y agoYes, part of it should be in C. Even if the Objective-C calls were portable (last time I checked GNUStep was pretty much dead) the APIs it calls into aren't. Seems to me like there's more value to just write the Objective-C parts in a .m file normally & call into the shared C/C++ code.
- duskwuff 9y ago> So why not just write the Objective-C part in C rather than calling the underlying machinery directly. Because the "underlying machinery" isn't documented by Apple. It may not even be a stable interface!
- ssalazar 9y agoIn fact it basically is: https://developer.apple.com/documentation/objectivec/objective_c_runtime https://developer.apple.com/documentation/objectivec/objecti...
- duskwuff 9y agoMy understanding of the parent post was that they meant whatever "underlying machinery" AppKit is calling into -- not just the ObjC runtime.
- vlovich123 9y agoI typo'ed. I meant to say why not right the Objective-C part in Objective-C. I see no value in writing it all in C because you lose all the compile-time checks the compiler is able to perform to catch bugs & the C interface, which AFAIK is ABI stable (would have to be since apps are forward-compatible), is really difficult to use.
- FraKtus 9y agoI did not mean you can make cross-platform programming thanks to this example but that you may avoid having objective C code in your project thanks to this. I know from personal experience that objective C makes some colleague "nervous" :-)