Protocol-oriented Objective-C 2.1 library for OS X (10.6-) and iOS (5.0-) development. ARC or no ARC.
Attempts to unify UIKit and AppKit programming by establishing an interface union between analogous classes in UIKit and AppKit.
For example, both UIView and NSView have a designated initializer initWithFrame:
However, NSView defines it this way:
And UIView defines it thusly:
By writing code using the GKApplication library, you can write this:
#import "GKView.h"' @interface MyView : GKView - (instancetype)initWithFrame:(GKRect)frame; @end // Under MacOS X, this code effectively expands to: @interface MyView : NSView - (instancetype)initWithFrame:(NSRect)frame; @end // Under iOS, this code expands to: @interface MyView : UIView - (instancetype)initWithFrame:(CGRect)frame; @end
When a method is missing from UIKit that AppKit includes, or vice-versa, GKApplication implements an analogous method with the exact prototype so that the code is uniform across platforms. One simply need change any UIKit code by changing all UIViews to GKViews, all CGRects to GKRect etc. Or, if porting from Cocoa to GKApplication, use GKViewController in place of NSViewController.
The resulting code is suprisingly uniform and portable.
( BEST CASE EXAMPLE https://github.com/genkiyooka/GKApplication/blob/master/GKColorPickerViewController.* )
It may seem counter-intuitive, but once these base symbols and protocols are established, it becomes quite easy to write code which runs uniformly on both iOS and Mac and behaves in a manner consistent across the platforms. Drawing with CoreGraphics functions will make the code more portable.
GKApplication provides the overall cross-platform basis for macOS/iOS development in the Nibitaph project.
FOR MORE INFORMATION