为啥程序运行的时候,总是出现这样的提示 Enumeration value...not handle in switch#import <Foundation/Foundation.h>typedef enum{ kCircle, kRectangle, kOblateShperold, kTrangle}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";}//colornamevoid drawCircle(ShapeRect bounds, ShapeColor fillColor)/*return 0;*/{ NSLog(@"drawing a circle at (%d %d %d %d) in %@", bounds.x, bounds.y, bounds.width, bounds.height, colorName(fillColor));} // drawCirclevoid drawRectangle(ShapeRect bounds, ShapeColor fillColor)/*return 0;*/{ NSLog(@"drawing a rectangle at (%d %d %d %d) in %@", bounds.x, bounds.y, bounds.width, bounds.height, colorName(fillColor));} // drawRectanglevoid drawEgg(ShapeRect bounds, ShapeColor fillColor)/*return 0;*/{ NSLog(@"drawing an egg at (%d %d %d %d) in %@", bounds.x, bounds.y, bounds.width, bounds.height, colorName(fillColor));} // drawEggvoid drawShapes (Shape shapes[], int count){ int i; for (i = 0; i<count; i++){ switch (shapes[i].type) { case kCircle: drawCircle (shapes[i].bounds, shapes[i].fillColor); break; case kRectangle: drawRectangle (shapes[i].bounds, shapes[i].fillColor); break; case kOblateShperold: drawEgg (shapes[i].bounds, shapes[i].fillColor); break; } }}//drawShapesint main(int argc, const char * argv[]){ Shape shapes[3]; ShapeRect rect0 = { 0, 0, 10, 30 }; shapes[0].type = kCircle; shapes[0].fillColor = kRedColor; shapes[0].bounds = rect0; ShapeRect rect1 = { 30, 40, 50, 60 }; shapes[1].type = kCircle; shapes[1].fillColor = kRedColor; shapes[1].bounds = rect1; ShapeRect rect2 = {15, 18, 37, 29 }; shapes[2].type = kOblateShperold; shapes[2].fillColor = KBlueColor; shapes[2].bounds = rect2; drawShapes (shapes, 3); return (0);}
解决方案 »
- 如何消除源代码中的开发证书?
- 如何修改tableview的宽度?
- 关于@synthesize object=_object,请各位赐教
- NSMutableURLRequest post 中文乱码,怎么办,已经是utf8
- iphone版面太冷清了阿
- [原创]兄弟我做了一个刷榜检测的工具,希望大家给提提意见
- iOS AVAudioPlayer 播放在线音频
- NSURLSession下载中强制退出,再次进入收到上次Task的失败结果
- NSDateFormatter 的dateFromString返回值为nil
- 今天早上收到苹果APP被拒邮件,新手小白求大神帮忙
- BMKMapManager.h 提示: Expected identifier or '('
- IOS 怎么弹出只显示一半的模态视图
kCircle=0,
kRectangle=1,
kOblateShperold,
kTrangle,
}ShapeType;
结果还是一样哦使用NS_ENUM定义试试
typedef NS_ENUM(NSInteger,ShapeType) {
kCircle=0,
kRectangle=1,
kOblateShperold=2,
kTrangle=3,
}