In Swift, the #import OC file is available in the bridge header file, and the entire Swift project can use the OC files, and the methods exposed in. h can be used by the project//oc file TestOC.h
1 #import2 3 4 5 @interfaceTestoc:nsobject6 7 8 9- (void) SayHello;Ten One- (void) Saywhat: (NSString *) name Andage: (NSString *) age; A -+ (void) Sayhellotwo; - the - - @end
Testoc.m
1 #import "TestOC.h"2 3 4 5 @implementationTestoc6 7- (void) SayHello8 9 {Ten OneNSLog (@"Hello to you"); A - } - the - -- (void) Saywhat: (NSString *) name Andage: (NSString *) Age - + { - +NSLog (@"%@,%@", name,age); A at } - - - -+ (void) Sayhellotwo - in { - toNSLog (@"I want to make friend with you"); + - the * } $ Panax Notoginseng - the @end
Bridge header File
#import "TestOC.h"
Swift file
Methods for calling OC files
1 Let he = Testoc ()23 He.sayhello ()45 6 7 he.saywhat ("achao", Andage:" " )89 testoc.sayhellotwo ()
It is clear that when calling OC's multi-parameter function in Swift, the first part of the function becomes the name of the Swift function before the parentheses, and then the first parameter of the function does not have a name, and the rest of the function seats the parameter name of the SWIFT function, which is the label
Calling a class method is directly a class name using point syntax calls, calling a multi-parameter class function, and so on
iOS development--The call of functional &swift and Object-c