4
votes

In Objective-C

CGPDFArrayRef array;

This works fine: Whereas in Swift it should be,

var array:CGPDFArrayRef

But it's giving this error when passes in the next line:

var success = CGPDFScannerPopArray(inScanner, &array)

Cannot pass immutable value as inout argument: implicit conversion from 'CGPDFArrayRef' to 'CGPDFArrayRef?' requires a temporary.

1
try this var array: CGPDFArrayRef? = nil - Anbu.Karthik
@Anbu.Karthik: Yes, that is the correct solution. - Martin R
@Hemang: Your updated code in the question compiles without problems. - Martin R
Yes, corrected. But the actual problem was different. - Hemang
thank you @Anbu ... there are times I wonder if the designers of Swift take pleasure in making what was supposed to be a simple language a truly convoluted one. Seriously. Whomever decided on forcing each of us to deal repeated with optional variables needs to be taking to the principal's office. - drew..

1 Answers

2
votes

I fixed it by passing the array like this:

var success = CGPDFScannerPopArray(inScanner, UnsafeMutablePointer(array))