Objc-C header definition:
- (int)printPDFAtPath:(NSString *)pdfPath pages:(NSUInteger [])indexes length:(NSUInteger)length copy:(int)nCopy;
Sample objc-C code to use this function:
NSUInteger pageIndexes[] = {0}; printResult = [self.ptp printPDFAtPath:selectedPDFFilePath pages:pageIndexes length:length copy:self.numberOfPaper];
Swift expects:
func printPDF(atPath pdfPath: String!, pages indexes: UnsafeMutablePointer<UInt>!, length: UInt, copy nCopy: Int32) -> Int32
How do I represent NSUInteger pageIndexes[] = {0};
in Swift as a UnsafeMutablePointer<UInt>
?
You can simply pass a Swift [UInt]
array as in-out argument with &
, this passes the address of the array element storage to the (Objective-)C function:
var pageIndexes: [UInt] = [1, 2, 3]
ptp.printPDF(atPath: "path", pages: &pageIndexes, length: UInt(pageIndexes.count), copy: 1)
For more information, see
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments