Objc-C标头定义:
- (int)printPDFAtPath:(NSString *)pdfPath pages:(NSUInteger [])indexes length:(NSUInteger)length copy:(int)nCopy;
使用此功能的objc-C代码示例:
NSUInteger pageIndexes[] = {0};
printResult = [self.ptp printPDFAtPath:selectedPDFFilePath pages:pageIndexes length:length copy:self.numberOfPaper];
雨燕期望:
func printPDF(atPath pdfPath: String!, pages indexes: UnsafeMutablePointer<UInt>!, length: UInt, copy nCopy: Int32) -> Int32
如何在Swift中将NSUInteger pageIndexes[] = {0};
表示为UnsafeMutablePointer<UInt>
?
答案 0 :(得分:3)
您可以简单地通过[UInt]
将Swift &
数组作为进出参数传递,这会将数组元素存储的地址传递给(Objective-)C函数:
var pageIndexes: [UInt] = [1, 2, 3]
ptp.printPDF(atPath: "path", pages: &pageIndexes, length: UInt(pageIndexes.count), copy: 1)
有关更多信息,请参见