Created
February 19, 2010 05:00
-
-
Save swannodette/308448 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
// ============================ | |
// MyClass | |
// ============================ | |
@class YourClass; | |
@interface MyClass : NSObject | |
{ | |
float myFloat; | |
YourClass *friend; | |
} | |
- (void) hello; | |
@end | |
@implementation MyClass | |
- (id) init | |
{ | |
self = [super init]; | |
if(self != nil) | |
{ | |
myFloat = 5.0; | |
} | |
return self; | |
} | |
- (void) hello | |
{ | |
NSLog(@"Hello, I'm your first Objective-C program!"); | |
} | |
- (void) dealloc | |
{ | |
// release any retained objects here. | |
[super dealloc]; | |
} | |
@end | |
// ============================ | |
// YourClass | |
// ============================ | |
@interface YourClass : NSObject | |
{ | |
// no variables | |
} | |
- (NSString *) goodbye; | |
@end | |
@implementation YourClass | |
- (id) init | |
{ | |
self = [super init]; | |
if(self != nil) | |
{ | |
// No variables | |
} | |
return self; | |
} | |
- (NSString *) goodbye | |
{ | |
return @"Goodbye, nice seeing you!"; | |
} | |
- (void) dealloc | |
{ | |
// release any retained objects here. | |
[super dealloc]; | |
} | |
@end | |
// ============================ | |
// main | |
// ============================ | |
int main(int argc, char**argv) | |
{ | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
// allocate an instance | |
MyClass *instance = [[MyClass alloc] init]; | |
[instance hello]; | |
[pool release]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment