Keyword |
Meaning |
super |
parent class |
self |
like "this" in other languages, means this class |
@ |
indicates an annotation |
+ (void) method(***) {} |
+ means this is a class method in a class
Invoke it on the class directly ---- this is like static method in other languages
[class method] |
- (void) method(***) {} |
- means this is an instance method in a class
Invoke it on an OBJECT/Instance of the class
[object method] |
nill |
like null or NULL in other languages |
@property var |
declaring that we want to create "accessor" methods for
class variable var
setVar(x) will be created
Var() will be created--get |
@property (a1,a2,*) var |
attributes like: nonatomic, readwrite, strong can go here
nonatomic / atomic |
Property value , dealing with threading
nonatomic = (YOU USE THIS)
nonatomic means its not thread-safe.
NOTE: no problem if this is UI code because all UI code happens
on the main thread of the application.
atomic = (dont do this for iOS)
default value, means thread safe
|
readwrite/readonly |
Property value
readwrite=
default value, declares both a setter and a getter.
readonly =
means only create setter method.
|
weak/strong/copy |
Property value , dealing with memory managment
assign= used for variables that are primitive data types (like int, float)
weak= means a weak reference to object stored in variable (see ARC memory management documentation online)
strong = means a stron reference to object stored in variable (see ARC memory management online)
copy = means make a copy of any value used to set the variable and assigns this... in essence this will become the setter method for the variable Var
- -(void) setVar:(type *) s
{ var = [s copy]; }
|
|
@synthesize |
Inside the .m file where you define methods -- autogenerates the methods
setVar(*) and Var() the setter and getter methods when declared in .h file using @property
NOTE: the setVar(x) method autogenerated only sets the class var to the value x |
@interface ClassName |
Start of defining a class in .h file |
@implementation ClassName |
Start of creating implementation of a class in .m file |
@end |
End of a class definition in either .h or .m file |
String Formatting (used in printf() and NSLog()) |
%d = int
%f = float
%c = char
|
@autoreleasepool |
Latest version of Objective-C uses Automatic
Reference Counting (kind of like automatic garbage collection)
----to handle getting rid of not needed items in memory (avoiding
memory leaks). YEAH! AUTOMATIC!
-----like Java this way
@autoreleasepool in a needed annotation around your main
block of code to “enable” this |