0% found this document useful (0 votes)
352 views

Objective C Cheat Sheet

The document provides definitions and examples for key concepts in Objective-C including messaging, method headers, interface definition, implementation, import, self, categories, protocols, properties and synthesis, inheritance, and id. It explains these concepts concisely and provides simple code examples to illustrate each one.

Uploaded by

zxmn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
352 views

Objective C Cheat Sheet

The document provides definitions and examples for key concepts in Objective-C including messaging, method headers, interface definition, implementation, import, self, categories, protocols, properties and synthesis, inheritance, and id. It explains these concepts concisely and provides simple code examples to illustrate each one.

Uploaded by

zxmn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Beginners

iPhone Objective-C 2.0 Cheat Sheet V4 ManiacDev.Com Created By Johann Dowa


Messaging
Definition: Sending Messages To Objects Examples: [object message] [object message: param1 withParameter: param2] [object secondMessage: [object message]] Similar To: Java/C++: object.method() Java/C++:object method(param1, param2) C++: object->method()

Method Headers
Definition: The first line of a method; The return type, method name , and parameters are stated. Examples: -(returnType)methodName -(returnType)methodName: (dataType)param1 -(returnType)methodName: (dataType)param1 withParam: (dataType)param2 Similar To C/C++ /Java: returnType methodName() returnType methodName(param1) returnType methodName(param2)

Interface Definition: Declaration in which class name, inheritance, variables, method names, and property is declared. Example: @interface ClassName: ParentClass <Protocol> { dataType variableName; } @property data; -(returnType)methodName: (dataType) param1 @end

Implementation
Definition: Declaration in which the actual class implementation is defined. Example: This is where you implement the actual class. @implementation ClassName @synthesize data; -(returnType)methodName: (dataType) param1 { ... Method Details ... } @end

Import
Definition: Importing is the inclusion of the source code of a specified file within the current file. Examples: #Import Class.h #Import <Class.h> #Import <director/Class.h>

Self
Definition: Identifier for the current class instantiation. Example: [self keyword] Similar to Java/C++ this keyword

Categories
Definition: A way of sectioning code. Categories are used for better code organization, and can be used to add methods to classes for which you do not have the source code. @interface ClassName (category) -(returnType)methodname; @end @implementation NSString (MyCoolAddition) - (returnType)methodName { Method Details } @end

Protocol
Definition: Class from which structure is inherited, not implementation. Example: @implementation className <protocol>

Property and Synthesize

Definition: @property declarations are declarations of a property used for automatic getter and setter creation. Definition: @synthesize declarations are implementions of a property used for automatic getter and setter creation. Example: in interface: @property dataType variableName in implementation: @synthesize variableName

Inheritance
Definition: The formation of a new class using an already defined class and/or protocol. Examples: ClassName: ParentClass ClassName:ParentClass <Protocol> ClassName <Protocol> Similar To: Java: ClassName extends ParentClass implements Interface C++: ClassName: Parentclass <interface>

Id
Definition: Keyword used as a generic identifier for any class. Example: id name Similar To Object Keyword in Java and void* in C++

You might also like