出错啦,求指导 linker commond fialed with exit code 1

   初学objective-c  写了一个小例子就除了这么个错,求大神指导,拜谢。
代码如下:
main.m
#import <Foundation/Foundation.h>
#import "Circle.h"

void drawShapes (id shapes[],int count)
{
    for (int i= 0; i< count; i++) {
        id shape = shapes[i];
        [shape draw];
    }
}
int main(int argc, const char * argv[]) {
    id shapes[3];
    ShapeRect rect0 ={0,0,10,30};
    shapes[0] = [Circle new];
    [shapes[0] setBounds:rect0];
    [shapes[0] setFillColor:KRedColor];
    
    
    ShapeRect rect1 ={30,40,50,60};
    shapes[1] = [Circle new];
    [shapes[1] setBounds:rect1];
    [shapes[1] setFillColor:KGreenColor];
    
    ShapeRect rect2 ={15,19,37,29};
    shapes[2] = [Circle new];
    [shapes[2] setBounds:rect2];
    [shapes[2] setFillColor:KBlueColor];
    drawShapes (shapes,3);
    return 0;
}

Circle.m #import "Circle.h"




@implementation Circle

-(void) setFillColor:(ShapeColor)c{
    
    fillColor =c;
    
}
-(void) setBounds:(ShapeRect)b{
    
    bounds=b;
}
-(void) draw{
    
    NSLog(@"drawing a circle at (%d %d %d %d) in %@",bounds.x,bounds.y
          ,bounds.width,bounds.height, colorName(fillColor));
    
}
@end

Circle.h
#import <Foundation/Foundation.h>
typedef enum {
    KCircle,
    KRectangle,
    KEgg
    
} ShapeType;

typedef enum {
    KRedColor,
    KGreenColor,
    KBlueColor
}ShapeColor;

typedef struct {
    int x,y ,width,height;
    
} ShapeRect;

typedef struct {
    
    ShapeType type;
    ShapeColor fillColor;
    ShapeRect bounds;
} Shape;

NSString *colorName(ShapeColor colorname)
{
    switch (colorname) {
        case KRedColor:
            return @"red";
            break;
        case KGreenColor:
            return @"green";
            break;
        case KBlueColor:
            return @"blue";
            break;
            
            
    }
    return @"no clue";
}

@interface Circle : NSObject
{
    
    
@private
    ShapeColor fillColor;
    ShapeRect bounds;
}
- (void) setFillColor : (ShapeColor) fillColor;
-(void) setBounds :(ShapeRect) bounds;
-(void) draw;
@end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值