// // main.m // mylearn // // #import <Foundation/Foundation.h> @interface Mypoint:NSObject -(void) print; -(void) setx:(int)x; -(void) sety:(int)y; @end @implementation Mypoint { int myx; int myy; } -(void) print{ NSLog(@"(%i,%i)",myx,myy); } -(void)setx:(int)x{ myx=x; } -(void)sety:(int)y{ myy=y; } @end int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... Mypoint *mypoint; mypoint=[Mypoint alloc]; [mypoint setx:10]; [mypoint sety:20]; NSLog(@"point:"); [mypoint print]; } return 0; }
2016-09-01 12:01:00.732 mylearn[822:97355] point:
2016-09-01 12:01:00.733 mylearn[822:97355] (10,20)