#import <Foundation/Foundation.h>
// 尽管编译器容错能力比较,但是写代码必须规范
@interface Person : NSObject
- (void)test;
@end
@implementation Person
- (void)test
{
NSLog(@"哈哈哈");
}
@end
// 一旦运行过程中出错,就会闪退
/*
-[Person test]: unrecognized selector sent to instance 0x7fd2ea4097c0
给Person对象发送了一个不能识别的消息:test
*/
int main()
{
Person *p = [Person new];
// OC是在运行过程中才会检测对象有没有实现相应的方法
[p test];
return 0;
}
灰摩托(huimotuo)http://www.cnblogs.com/huimotuo/
浙公网安备 33010602011771号