简体   繁体   中英

C bindings for Cocoa API?

My relations with Objective-C and XCode are perfectly summarized as «hate from the first sight». Emotional as it is, I`d still like to develop GUI apps in C, the way I`m used to (.C files, .H files, Makefile and Clang), even for MacOS X ≥ 10.8.

I know that long ago there was Carbon , but now it`s of no use. CoreFoundation is good, especially in cases where the so-called toll-free bridging to NS* classes is available, but it`s only a scarce subset of what Cocoa has.

The question is: are there any ready to use C bindings to Cocoa?

I`ve almost succeeded in writing these myself, even with a makeshift subclass factory to support delegating, but then a thought stroke me: I`m definitely not the first one. However, all that I could google out was this and this .

…okay.

After much struggle, I`ve finally come up with a usable solution, even though it`s nowhere near complete.

https://github.com/hidefromkgb/mac_load

This is a header-only Cocoa C binding. The main drawbacks are:

  1. it covers much less than 1% of all Cocoa API;
  2. its own helper functions are, for now, subject to rapid change;
  3. it`s still undocumented.

Anyway, it does help write Cocoa code in readable C — a tiny subset of what`s actually possible with Cocoa, but now the measure of this subset only depends on function coverage.

Here`s an example of what it can do:

https://github.com/hidefromkgb/msu3-waves/tree/master/macos

PS: don`t trust GitHub language analyzer, there`s not a single line of ObjC-specific code here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM