Archive

Posts Tagged ‘development’

NSObject as a base class in iPhone SDK

October 15th, 2009 volody No comments

The NSObject protocol groups methods (NS stands for NEXTSTEP) are fundamental to all Objective-C objects. In Mac OS X v10.5 and later, developer can use automatic memory management by adopting garbage collection, as it described in Garbage Collection Programming Guide.

A simple Window-Based Application iPhone app could be created in XCode, with next code right after line :
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSObject *obj; // declare variable
obj = [NSObject alloc]; // allocate variable
[obj init]; // initialize variable
NSLog(@”Option 2:%@\n”, obj); // output variable declaration into console

This NSLog output is sent to Console. To test this code goto Run -> Console -> Build and Go.

Categories: iPhone Tags: