You are on page 1of 1

 

Beginners  iPhone  Objective-­‐C  2.0  Cheat  Sheet  V4  –  ManiacDev.Com  –  Created  By  Johann  Dowa  
Messaging   Method  Headers    Interface   Implementation  
Definition:  Sending  Messages  To  Objects   Definition:    The  first  line  of  a  method;  The   Definition:  Declaration  in  which  class  name,   Definition:  Declaration  in  which  the  actual  class  
  return  type,  method  name  ,  and  parameters   inheritance,  variables,  method  names,  and   implementation  is  defined.  
Examples:   are  stated.   property  is  declared.    
[object  message]       Example:  
[object  message:  param1  withParameter:   Examples:   Example:   This  is  where  you  implement  the  actual  class.  
param2]   -­‐(returnType)methodName   @interface  ClassName:  ParentClass  <Protocol>  
@implementation  ClassName  
[object  secondMessage:  [object  message]]   -­‐(returnType)methodName:  (dataType)param1   {  
  -­‐(returnType)methodName:  (dataType)param1          dataType  variableName;   @synthesize  data;  
Similar  To:   withParam:  (dataType)param2   }  
-­‐(returnType)methodName:  (dataType)  
Java/C++:  object.method()     @property  data;  
param1  
Java/C++:object  method(param1,  param2)   Similar  To  C/C++  /Java:  
-­‐(returnType)methodName:  (dataType)   {  
C++:  object-­‐>method()   returnType  methodName()  
param1          ...  Method  Details  ...  
  returnType  methodName(param1)  
}  
@end  
Import   returnType  methodName(param2)  
@end  
   
Definition:  Importing  is  the  inclusion  of  the    
source  code  of  a  specified  file  within  the   Self   Categories     Protocol  
current  file.   Definition:  Identifier  for  the  current  class   Definition:  A  way  of  sectioning  code.    
Definition:  Class  from  which  structure  is  
  instantiation.   Categories  are  used  for  better  code  
inherited,  not  implementation.  
Examples:     organization,  and  can  be  used  to  add  methods  
 
#Import    “Class.h”   Example:   to  classes  for  which  you  do  not  have  the  source  
Example:  
#Import    <Class.h>   [self  keyword]   code.  
@implementation  className  <protocol>  
#Import  <director/Class.h>    
Similar  to    Java/C++  this  keyword    
  @interface  ClassName  (category)  
  Id  
Property  and  Synthesize   Inheritance  
         -­‐(returnType)methodname;  
@end   Definition:  Keyword  used  as  a  generic  identifier  
Definition:    @property  declarations  are  
Definition:  The  formation  of  a  new  class  using   for  any  class.  
declarations  of  a  property  used  for  automatic   @implementation  NSString  (MyCoolAddition)  
an  already  defined  class  and/or  protocol.    
getter  and  setter  creation.   -­‐  (returnType)methodName    
  Example:  
Definition:  @synthesize  declarations  are   {    
Examples:   id  name  
implementions  of  a  property  used  for            …  Method  Details  …  
ClassName:  ParentClass    
automatic  getter  and  setter  creation.   }  
ClassName:ParentClass  <Protocol>   Similar  To  Object  Keyword  in  Java  and  void*    in  
 
ClassName  <Protocol>   C++
Example:   @end
 
in  interface:  @property  dataType  
Similar  To:  
variableName  
Java:  ClassName  extends  ParentClass  
in  implementation:  @synthesize  variableName
implements  Interface  
C++:  ClassName:  Parentclass  <interface>
 

You might also like