objc:make

(objc:make objc-class-name init-signature . args)


Description:

Create and return a new objective C object initialized using the init-signature and an optional obj-c argument. Make sure you only call init methods!!  To call methods on an existing objc-object or to return a new objc-object from a class method use objc:call.


Arguments:

objc-class-name -- string name of obj-c class

           args -- optional argument to pass to init-signature.  args can be either objc-objects, reals, integers, strings (which get converted to NSString), #t or #f, or a list of 2 (NSSize,NSRange,NSPoint) or 4 (NSRect) elements.

 init-signature -- initialization signature ("init" or "initWithString" etc.)


Returns: obj-c object or #f on fail


Related: objc:call string->objc objc->string number->objc objc->number objc:print 


Examples:

(define nsarray (objc:make "NSMutableArray" "init"))

(define nsstring (string->objc "string1"))

(define nsnumber (number->objc 1.0))

(objc:call nsarray "addObject:" nsstring)

(objc:call nsarray "addObject:" nsnumber)

(print nsstring nsnumber nsarray)



Back to index