區別
- 函數:屬于整個文件,可以直接調用
- 方法:依賴于類,只能通過實例對象或者類調用
#import "TestViewController.h"
static void method_002(){
NSLog(@"--- %s----", __func__);
}
extern void method_003(){
NSLog(@"--- %s----", __func__);
}
@interface Math : NSObject
@end
@implementation Math
- (void)method_001{
NSLog(@"--- %s----", __func__);
}
@end
@interface TestViewController ()
@end
@implementation TestViewController
- (void)viewDidLoad {
[super viewDidLoad];
//方法調用
Math *m = [Math new];
[m method_001];
//函數調用
method_002();
method_003();
}
@end