IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]oc笔记-3

    u010255642发表于 2016-09-04 21:48:56
    love 0
    //
    //  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)





沪ICP备19023445号-2号
友情链接