Search code examples
iphoneinitializationclass-designsubclass

How to initialize an NSObject's subclass on iPhone?


I want to write some methods in a class so that other classes can call these methods using [instance methodName:Parameter].

If the class is a subclass of UIViewController, I can use initWithNibName to initialize it. But I want to write the methods in an NSObject's subclass, how can I initialize it?


Solution

  • I find this may work:

    TheClass *newObject = [[TheClass alloc] init];
    //do something here
    [newObject release];