An existing objective-C method has the following signature:
-(BOOL)barcodeSetScanBeep:(BOOL)enabled volume:(int)volume beepData:(int *)data length:(int)length er
int
is a C 32-bit integer and mapped to Swift as Int32
.
A int *
parameter is mapped to Swift as UnsafeMutablePointer
,
and you can pass a variable array as "inout parameter" with &
.
So it should roughly look like this:
var beepData : [ Int32 ] = [ 1200, 100 ]
var error : NSError?
if !DTDevices.sharedDevice().barcodeSetScanBeep(true, volume: Int32(100),
beepData: &beepData, length: Int32(beepData.count),
error: &error) {
println(error!)
}
Swift defines also a type alias
/// The C 'int' type.
typealias CInt = Int32
so you could replace Int32
by CInt
in above code if you want to emphasize that
you are working with C integers.
For more information, see "Interacting with C APIs" in the "Using Swift with Cocoa and Objective-C" documentation.