黑马程序员技术交流社区
标题: 常见错误汇总 [打印本页]
作者: 小蜗19910109 时间: 2015-10-15 22:37
标题: 常见错误汇总
#import <Foundation/Foundation.h>
@interface Dog : NSObject
@end
@interface Car : NSObject
{
@public
int _lunzi;
}
//@interface Person :NSObject
//
//@end
-(void)stop;
@end
@implementation Dog
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
Car *car = [Car new];
car->_lunzi = 4;
printf("%d\n",car->_lunzi);
@try {
//有可能会出错的代码
[car stop]; //语法检查上没有问题,运行时时错误的
}
@catch (NSException *exception) {
//错误的处理方法
NSLog(@"出错了,您调用的方法没有实现!");
NSLog(@" %@ ",exception); //打印出错误的信息
}
@finally {
printf("xxxxxx\n");
}
}
return 0;
}
///Users/apple/Desktop/1222iOS基础班/课程内容/OC部分/0117/code/OC2-对象和方法之间的关系/06-常见错误汇总/main.m:50:17: Method definition for 'stop' not found
@implementation Car
@end
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) |
黑马程序员IT技术论坛 X3.2 |