Objective-C tips

トップ > チップス > Objective-C tips
2012-02-14, objc

The NSLog function understands the conventions used by the standard C library printf function, including %f for floats and %d for integers, but in addition uses %@ for objects:

NSLog( @"Prints the UILabel object %@ to the console.", label);

Although NSObject is the most common root class, it is not the only one. For instance, NSProxy is also a root class.

The declaration of properties using the @property compiler directive is a convenience to avoid the declaration and, usually, the implementation of accessor methods for member variables.

When you declare an @property in the class interface, you must also synthesize the property (unless you wish to implement the getter and setter methods yourself) using the @synthesize declaration.

In Objective-C, the nil object is functionally equivalent to the NULL pointer found in many other C-derived languages. However, unlike most of these languages, it is permissible to call methods on nil without causing your application to crash.

NS = Next Step

$ open -h NSSting

NSTimer

この記事は役に立ちましたか?