Tutorial by Examples

The BOOL type is used for boolean values in Objective-C. It has two values, YES, and NO, in contrast to the more common "true" and "false". Its behavior is straightforward and identical to the C language's. BOOL areEqual = (1 == 1); // areEqual is YES BOOL areNotEqual = !ar...

id

id is the generic object pointer, an Objective-C type representing "any object". An instance of any Objective-C class can be stored in an id variable. An id and any other class type can be assigned back and forth without casting: id anonymousSurname = @"Doe"; NSString * surname...

SEL

Selectors are used as method identifiers in Objective-C. In the example below, there are two selectors. new and setName: Person* customer = [Person new]; [customer setName:@"John Doe"]; Each pair of brackets corresponds to a message send. On the first line we send a message containin...
IMP is a C type referring to the implementation of a method, also known as an implementation pointer. It is a pointer to the start of a method implementation. Syntax: id (*IMP)(id, SEL, …) IMP is defined by: typedef id (*IMP)(id self,SEL _cmd,…); To access this IMP, the message “methodForSe...
The NSInteger is just a typedef for either an int or a long depending on the architecture. The same goes for a NSUInteger which is a typedef for the unsigned variants. If you check the NSInteger you will see the following: #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_...

Page 1 of 1