// // main.m // mylearn // #import <Foundation/Foundation.h> #import "Mypoint.h" @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; } -(int) myx{ return myx; } -(int) myy{ return myy; } +(void)sayhello{ NSLog(@"hello"); } @end int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... Mypoint *mypoint; [Mypoint sayhello]; mypoint=[Mypoint alloc]; mypoint=[mypoint init]; [mypoint setx:10]; [mypoint sety:20]; NSLog(@"point:"); NSLog(@"%i",[mypoint myx]); [mypoint print]; } return 0; }
2016-09-04 21:46:29.977 mylearn[502:14739] hello
2016-09-04 21:46:29.979 mylearn[502:14739] point:
2016-09-04 21:46:29.979 mylearn[502:14739] 10
2016-09-04 21:46:29.980 mylearn[502:14739] (10,20)