summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--objective-c.html.markdown13
1 files changed, 11 insertions, 2 deletions
diff --git a/objective-c.html.markdown b/objective-c.html.markdown
index a70351b5..e1834bf8 100644
--- a/objective-c.html.markdown
+++ b/objective-c.html.markdown
@@ -306,10 +306,11 @@ int main (int argc, const char * argv[])
// Methods
+/- (return type)methodSignature:(Parameter Type *)parameterName;
-// + for class method
+// + for class method.
+ (NSString *)classMethod;
++ (MyClass *)myClassFromName:(NSString *)name;
-// - for instance method
+// - for instance methods.
- (NSString *)instanceMethodWithParameter:(NSString *)string;
- (NSNumber *)methodAParameterAsString:(NSString*)string andAParameterAsNumber:(NSNumber *)number;
@@ -329,6 +330,14 @@ myClass.count = 45;
NSLog(@"%i", myClass.count); // prints => 45
+// Call class methods:
+NSString *classMethodString = [MyClass classMethod];
+MyClass *classFromName = [MyClass myClassFromName:@"Hello"];
+
+// Call instance methods:
+MyClass *myClass = [[MyClass alloc] init]; // Create MyClass object instance.
+NSString *stringFromInstanceMethod = [myClass instanceMethodWithParameter:@"Hello"];
+
// Implement the methods in an implementation (MyClass.m) file:
@implementation MyClass {
long distance; // Private access instance variable.