xcode 入门事例

//

//  main.m

//  lance

//

//  Created by ledaoruanjian on 13-1-16.

//  Copyright (c) 2013年 ledaoruanjian. All rights reserved.

//



#import <UIKit/UIKit.h>

#import "AppDelegate.h"

#import "Hello.h"



int main(int argc, char *argv[])

{

    //NSAutoreleasePool *pool = [[3NSAutoreleasePool alloc] init];

    Hello *hello = [[Hello alloc] init];

    

    [hello primalSetData:2000 :01 :01];

    [hello displayDateInfo];

    [hello setData:2010	 iMonth:1 iDay:1];

    [hello displayDateInfo];

    [hello setYear:1982];

    [hello displayDateInfo];

    

    NSArray *arr1 = [NSArray arrayWithObjects:@"hello", hello, nil];

    int count = [arr1 count];

    for (int i=0; i<count; i++) {

        NSLog(@"i=%d,value=%@",i,[arr1 objectAtIndex:i]);

    }

    

    @autoreleasepool {

        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

    }

}

 

//

//  Hello.m

//  lance

//

//  Created by ledaoruanjian on 13-1-16.

//  Copyright (c) 2013年 ledaoruanjian. All rights reserved.

//



#import "Hello.h"



@implementation Hello

int iYear;

int iMouth;

int iDay;

-(void) displayDateInfo{

    NSLog(@"Today is %d %d %d/n",iYear,iMouth,iDay);

}

-(void) setYear:(int)year{

    iYear = year;

}

-(void) primalSetData:(int)year :(int)month :(int)day{

    iYear = year;

    iMouth = month;

    iDay = day;

}

-(void) setData:(int)year iMonth:(int)month iDay:(int)day{

    iYear = year;

    iMouth = month;

    iDay = day;

}

@end

//

//  Hello.h

//  lance

//

//  Created by ledaoruanjian on 13-1-16.

//  Copyright (c) 2013年 ledaoruanjian. All rights reserved.

//



#import <Foundation/Foundation.h>



@interface Hello : NSObject

-(void) setYear:(int)iYear;

-(void) primalSetData:(int)iYear:(int)iMouth:(int)iDay;

-(void) setData:(int)Year iMonth:(int)iMonth iDay:(int)iDay;

-(void) displayDateInfo;

@end

 

你可能感兴趣的:(xcode)