Runtime Functions
The Apple Objective-C runtime provides many C functions for interacting with the runtime. Most of the runtime functions are described in Appendix A. However, four runtime functions are used commonly and deserve explanation here.
Class NSClassFromString(NSString *aClassName) NSString *NSStringFromClass(Class aClass) NSString *NSStringFromSelector(SEL aSelector) SEL NSSelectorFromString(NSString *aSelectorName)
The first two methods convert from a string to a reference to the class named by the string and back. Uses of NSClassFromString() include allowing a user to input the name of a class to use. For example, an application could parse a text configuration file that specifies which classes to use in the application.
The ...
Get Cocoa® Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.