Contents (package MULK.OBJECTIVE-CL)


Function FIND-OBJC-CLASS

Purpose:

Retrieve an Objective-C class by name.

Syntax:

find-objc-class class-name &optional errorp

Arguments and Values:

class-name --- a symbol or a string.

errorp --- a generalized boolean.

Returns: class --- an objective-c-class object representing the Objective C class whose name is class-name.

Description:

If no Objective-C class named by class-name is found, the behaviour depends on errorp:: If errorp is true, an error is signaled. If errorp is false (which is the default), nil is returned.

If class-name is a symbol which does not contain a hyphen, its name is converted to lowercase except for the first letter, which is left intact, and the resulting string used as if directly given as an argument to find-objc-class.

If class-name is a symbol which contains a hyphen, its name is split into components separated by hyphens and each component converted into a string according to the following rules:

  1. The first component is fully converted to uppercase except for its first letter, which is left intact.

  2. Any additional components have all of their letters converted to lowercase, except for their first letters, which are left intact.

After that, the components are concatenated in order and the resulting string used as if directly given as an argument to find-objc-class.

Examples:

(find-objc-class "NSObject")     ;=> #<NS:+NS-OBJECT NS:NS-OBJECT {B5C1C480}>  
(find-objc-class 'ns-object)     ;=> #<NS:+NS-OBJECT NS:NS-OBJECT {B5C1C480}>  
(find-objc-class 'nsobject)      ;=> NIL  
 

Rationale:

The first component of an Objective-C class name is conventionally thought of as a namespace identifier. It is therefore sensible to expect it to be converted to uppercase by default, which is the conventional case for namespace identifiers in Objective-C.