Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created September 9, 2011 02:10
Show Gist options
  • Save ejknapp/1205329 to your computer and use it in GitHub Desktop.
Save ejknapp/1205329 to your computer and use it in GitHub Desktop.
//
// main.m
// First
//
// Created by Eric Knapp on 9/8/11.
// Copyright 2011 Madison Area Technical College. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Car.h"
int main (int argc, const char * argv[])
{
Car *car1 = [[Car alloc] init];
car1.model = @"Accord";
car1.year = 2000;
//[car1 setModel:@"Accord"];
// insert code here...
NSLog(@"My car model is %@", car1.model);
NSLog(@"model year: %@", [car1 modelYear]);
return 0;
}
//
// Car.m
// First
//
// Created by Eric Knapp on 9/8/11.
// Copyright 2011 Madison Area Technical College. All rights reserved.
//
#import "Car.h"
@implementation Car
@synthesize model = _model;
@synthesize year = _year;
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
-(NSString *)modelYear
{
NSString *modelYearString = [[NSString alloc]
initWithFormat:@"model: %@, year: %d",
self.model,
self.year];
return modelYearString;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment