zoukankan      html  css  js  c++  java
  • 为MYPoint类写一个分类

     1 #import <Foundation/Foundation.h>
     2 //xieyi
     3 @protocol showOn
     4 @required 
     5 -(void)printOn;
     6 @end
     7 // lei
     8 @interface MyPoint : NSObject<showOn,NSCopying>{
     9     int x;
    10     int y;
    11 }
    12 @property (nonatomic,assign)int x,y;
    13 -(id)initWithX:(int)_x andY:(int)_y;
    14 @end
    15 // leibie fenlei
    16 @interface MyPoint(MoveSet)
    17 
    18 -(void)moveToX:(int)_x andY:(int)_y;
    19 
    20 @end
    21 
    22 
    23 #import "MyPoint.h"
    24 
    25 @implementation MyPoint
    26 @synthesize x,y;
    27 
    28 -(id)initWithX:(int)_x andY:(int)_y{
    29     if(_x==0)
    30         x=1;
    31     if(_y==0)
    32         y=1;
    33     x=_x;
    34     y=_y;
    35     return self;
    36 }
    37 
    38 -(id)copyWithZone:(NSZone *)zone{
    39     MyPoint* newPoint=[[MyPoint allocWithZone:zone] initWithX:x andY:y];
    40     return newPoint;
    41 }
    42 
    43 -(void)printOn{
    44     NSLog(@" x = %d , y = %d ",x,y);
    45 }
    46 
    47 @end
    48 
    49 @implementation MyPoint(MoveSet)
    50 
    51 -(void)moveToX:(int)_x andY:(int)_y{
    52     x=_x;
    53     y=_y;
    54 }
    55 
    56 @end
  • 相关阅读:
    transform:translate -50%解释
    无缝滚动条
    css二维画面练习-扑克牌
    css二维动画
    ORM了解
    socket总结
    2016/9/23总结电脑内容
    winform控件跨线程委托
    HttpRequestMessage
    vue设置每个页面的头部title
  • 原文地址:https://www.cnblogs.com/wsq724439564/p/3272967.html
Copyright © 2011-2022 走看看