LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual > 1 Introduction to the Objective-C Interface > 1.3 Invoking Objective-C methods

NextPrevUpTopContentsIndex

1.3.6 Invoking a method that returns a string or array

The Objective-C classes NSString and NSArray are used extensively in Cocoa to represent strings and arrays of various objects. When a method that returns these types is called with invoke, the result is a foreign pointer of type objc-object-pointer as for other classes.

In order to obtain a more useful Lisp value, invoke-into can be used by specifying a type as the extra initial argument. For a method that returns NSString , the symbol string can be specified to cause the foreign object to be converted to a string. For a method that returns NSArray , the symbol array can be specified and the foreign object is converted to an array of foreign pointers. Alternatively a type such as (array string) can be specified and the foreign object is converted to an array of strings.

For example, the form

(invoke object "descrription")

will return a foreign pointer, whereas the form

(invoke-into 'string object "description")

will return a string.


LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex