5 ms·
Call it from an extern C function in an .m file?
by 0x0 7y ago
Call it from an extern C function in an .m file?
- vbezhenar 7y agoNot very practical, if you need to use a lot of APIs. One of advantage of Objective C is that it's easy to interop with C.
- pjmlp 7y agoYou are seeing the other way around. That advantage is to migrate C code into Objective-C, just like C++ and TypeScript have done as well. In fact, NeXTSTEP and its derived OSes have very little pure C code, beyond BSD/XNU kernel and the POSIX APIs.
- monocasa 7y agoYou'd be surprised. The new APFS.Framework appears to be all C for instance.
- pjmlp 7y agoEven then you're supposed to actually use the higher level filesystem framework APIs from Objective-C and Swift. https://developer.apple.com/documentation/foundation/file_system/about_apple_file_system https://developer.apple.com/documentation/foundation/file_sy...
- monocasa 7y agoI mean, yeah, you're not "supposed to" use it; it's a private framework. Also, the only reason why someone like me would know if it's in C or not is that I need one of the aspects of that library that can't be expressed in the high level APIs. My point is that there's tons of non legacy C code, in the OS outside of the kernel and posix subsystems on *OS.
- saagarjha 7y agoCoreFoundation?
- pjmlp 7y agoThe migration framework from Mac OS into OS X.
- 0x0 7y agoIf you need to use a lot of APIs, why not rename your source code file from .c to .m and just call them with ObjC syntax then?