mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 06:47:54 +02:00
Line length edits to objective c
This commit is contained in:
@@ -11,7 +11,7 @@ filename: LearnObjectiveC.m
|
|||||||
Objective-C is the main programming language used by Apple for the OS X and iOS operating systems and their respective frameworks, Cocoa and Cocoa Touch.
|
Objective-C is the main programming language used by Apple for the OS X and iOS operating systems and their respective frameworks, Cocoa and Cocoa Touch.
|
||||||
It is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.
|
It is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.
|
||||||
|
|
||||||
```Objective-C
|
```cpp
|
||||||
// Single-line comments start with //
|
// Single-line comments start with //
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -180,7 +180,8 @@ int main (int argc, const char * argv[])
|
|||||||
@try
|
@try
|
||||||
{
|
{
|
||||||
// Your statements here
|
// Your statements here
|
||||||
@throw [NSException exceptionWithName:@"FileNotFoundException" reason:@"File Not Found on System" userInfo:nil];
|
@throw [NSException exceptionWithName:@"FileNotFoundException"
|
||||||
|
reason:@"File Not Found on System" userInfo:nil];
|
||||||
} @catch (NSException * e)
|
} @catch (NSException * e)
|
||||||
{
|
{
|
||||||
NSLog(@"Exception: %@", e);
|
NSLog(@"Exception: %@", e);
|
||||||
@@ -198,9 +199,10 @@ int main (int argc, const char * argv[])
|
|||||||
// An object is not fully functional until both steps have been completed.
|
// An object is not fully functional until both steps have been completed.
|
||||||
MyClass *myObject = [[MyClass alloc] init];
|
MyClass *myObject = [[MyClass alloc] init];
|
||||||
|
|
||||||
// The Objective-C model of object-oriented programming is based on message passing to object instances.
|
// The Objective-C model of object-oriented programming is based on message
|
||||||
|
// passing to object instances.
|
||||||
// In Objective-C one does not simply call a method; one sends a message.
|
// In Objective-C one does not simply call a method; one sends a message.
|
||||||
[myObject instanceMethodWithParmeter:@"Steve Jobs"];
|
[myObject instanceMethodWithParameter:@"Steve Jobs"];
|
||||||
|
|
||||||
// Clean up the memory you used into your program
|
// Clean up the memory you used into your program
|
||||||
[pool drain];
|
[pool drain];
|
||||||
@@ -241,7 +243,7 @@ int main (int argc, const char * argv[])
|
|||||||
// - for instance method
|
// - for instance method
|
||||||
- (NSString *)instanceMethodWithParmeter:(NSString *)string;
|
- (NSString *)instanceMethodWithParmeter:(NSString *)string;
|
||||||
- (NSNumber *)methodAParameterAsString:(NSString*)string andAParameterAsNumber:(NSNumber *)number;
|
- (NSNumber *)methodAParameterAsString:(NSString*)string andAParameterAsNumber:(NSNumber *)number;
|
||||||
-
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// Implement the methods in an implementation (MyClass.m) file:
|
// Implement the methods in an implementation (MyClass.m) file:
|
||||||
@@ -291,7 +293,7 @@ int main (int argc, const char * argv[])
|
|||||||
* A protocol declares methods that can be implemented by any class.
|
* A protocol declares methods that can be implemented by any class.
|
||||||
* Protocols are not classes themselves. They simply define an interface
|
* Protocols are not classes themselves. They simply define an interface
|
||||||
* that other objects are responsible for implementing.
|
* that other objects are responsible for implementing.
|
||||||
* /
|
*/
|
||||||
@protocol MyProtocol
|
@protocol MyProtocol
|
||||||
- (void)myProtocolMethod;
|
- (void)myProtocolMethod;
|
||||||
@end
|
@end
|
||||||
|
Reference in New Issue
Block a user