On a side-note: I would like to apologize if the title is misleading. Couldn't find a better title for this question.
I imported the NDHTMLtoPDF library to my Xcode application.
In the demo of the library, this is how they use the library:
class NDViewController :UIViewController, NDHTMLtoPDFDelegate
{
var PDFCreator:NDHTMLtoPDF?
[...]
@IBAction func generatePDFUsingDelegate( sender:AnyObject ){
self.resultLabel?.text = "loading..."
let tt:NSString = ("~/Documents/delegateDemo.pdf" as NSString).stringByExpandingTildeInPath
self.PDFCreator = NDHTMLtoPDF.createPDFWithURL(NSURL(string:"http://edition.cnn.com/2012/11/12/business/china-consumer-economy/index.html?hpt=hp_c1")!, pathForPDF:tt, delegate: self, pageSize: CGSizeMake(595.2,841.8), margins:UIEdgeInsetsMake(10, 5, 10, 5)) as? NDHTMLtoPDF;
}
}
In my application, I do the same thing: I declare the PDFCreator
variable as an NDHTMLtoPDF?
type, I added NDHTMLtoPDFDelegate
at the class declaration where I use the library instance, and I wrote the following code in my method:
let tt:NSString = ("~/Documents/delegateDemo.pdf" as NSString).stringByExpandingTildeInPath
self.PDFCreator = NDHTMLtoPDF!.createPDFWithHTML("Hello", pathForPDF: tt, pageSize: CGSizeMake(595.2,841.8), margins:UIEdgeInsetsMake(36, 36, 36, 36))
Every time I type self.PDFCreator = NDHTMLtoPDF!.
, I only get autocompletes for the following methods:
createPDFWithHTML(self:NDHTMLToPDF)
createPDFWithURL(self:NDHTMLToPDF)
If I type self.PDFCreator = NDHTMLtoPDF.
, Xcode complains that this is an ambiguous reference to member <insert_member_here>
.
However, if I do self.PDFCreator.
, I suddenly get createPDFWithURL( URL:NSURL ,pathForPDF PDFpath:NSString ,delegate:AnyObject ,pageSize:CGSize ,margins pageMargins:UIEdgeInsets )
as an autocomplete option. I attempted to run my code with that only, but it turns out the method is never called (I checked by adding print
calls in the methods).
I am seriously at a loss.
Thank you for any help you may provide!
If you need any extra code, let me know.
So after fiddling with it some more, I figured it out. The solution is simple: update the code to the latest Swift 2.0
syntax.
I took the liberty of forking the repository and fixing it myself. I made a pull request, but if you want to get a copy of it before they merge it into the official master branch, go grab it here.