#import <Foundation/Foundation.h>
@interface Test : NSObject
//在OC中,每一个:后带一个形参
- (void)printTwoNumbers:(NSInteger)num1 : (NSInteger)num2;
@end
@implementation Test
//interface里面申明过的方法,必须在implementation里进行实现
- (void)printTwoNumbers:(NSInteger)num1 :(NSInteger)num2{
NSLog(@"num1=%ld,num2=%ld",num1,num2);
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
Test* t1 = [Test new];
[t1 printTwoNumbers:5 :7];
}
return 0;
}
优点:
1.可读性高
#import <Foundation/Foundation.h>
@interface Test : NSObject{
NSInteger _num1;
NSInteger _num2;
NSInteger _num3;
}
//在OC中,每一个:后带一个形参
- (void)printTwoNumbers:(NSInteger)num1 : (NSInteger)num2;
-(void)printTwoString1:(NSString*)str1 String2: (NSString*)str2;
-(void)creatWIthNum1:(NSInteger)num1 Number2:(NSInteger)num2 Nu