1. In the swift file is not able to write C language functions, not compatible with C, direct error. To invoke the C-language function, use the bridged functionality provided by the system, just as you would call OC in Swfit!
2. Swift 2.0 provides @convention (c) to convert Swift's closure function into a C language pointer. This feature is used in the following scenario,
In the C language file, we define a function:
cgfloat mycfunction (CGFloat (callback) (CGFloat x, cgfloat y)) { return callback (1.1 2.2 );}
The callback function here is a C-language function pointer, which we can use in Swift:
Let Swiftcallback: @convention (c) (CGFloat, cgfloat)-cgfloat = { in return x += mycfunction (swiftcallback)
The following simplified methods are also available:
Let result = mycfunction ({ in return x + y})
Some small knowledge of IOS Swift (constantly replenished)