cocoa :: foundation
The Foundation Kit provides basic Objective-C classes and structurescore :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Test extern classes from the Cocoa framework and extern factories
module cocoa_extern_types is example
import cocoa
in "ObjC Header" `{
// for `NSString::hello`
#import <Foundation/Foundation.h>
`}
redef extern class NSString
# Additionnal factory
new hello in "ObjC" `{ return @"Factory Hello"; `}
end
# Print a custom string to the log
fun nslog(text: NSString) in "ObjC" `{
NSLog(text);
`}
nslog "Hello using to_nsstring".to_nsstring
nslog new NSString.hello
var msg_box = new NSAlert
msg_box.message_text = "From Nit".to_nsstring
if "NIT_TESTING".environ != "true" then msg_box.run_modal
lib/cocoa/examples/cocoa_extern_types.nit:17,1--43,57