Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created February 19, 2010 05:00
Show Gist options
  • Save swannodette/308448 to your computer and use it in GitHub Desktop.
Save swannodette/308448 to your computer and use it in GitHub Desktop.
#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