Help with NSData and dataWithPDFInsideRect


I have a Web View that loads a HTML form and I am getting the content of the Web View and creating a PDF from it. My app however keeps crashing after creating the NSData object using dataWithPDFInsideRect. Basically whenever I try to do anything with the Web View, I get an error. Here is the order of events:

Create a PDF data object and save the PDF to disk: (this works fine)

set pdfData to webView's mainFrame's frameView's documentView's dataWithPDFInsideRect_((webView's mainFrame's frameView's documentView's frame()))
tell current application's class "PDFDocument" to set pdfDocument to alloc()'s initWithData_(pdfData)
pdfDocument's writeToFile_(outputPath)

If I then try to do pretty much anything else with the variable webView, my app crashes. Even just trying to recall the window that the webView is in crashes the app. I can, however, do something like

webView's setMainFrameURL_("")

But again, if I try something like makeKeyAndOrderFront on the window containing the Web View or try isLoading on the Web View itself, I get an errors such as the following:

Any ideas? Thank you in advance!

First of all, you should stop skipping the parentheses after method names. Sometimes it works, but sometimes it has unintended consequences. So it’s mainFrame() and frameView(), and so on.

Second, your two snippet are using different outlets: webView in the first, and mainWebView in the second.


Thanks for the response. The variable/outlet mismatch is a mis-type on my part here in the fourm. The variable is consistent in the app. I’ll try adding the parenthesis and see if that helps.

I don’t know why I skipped adding them…

Well I don’t know what was wrong with my Web View, but I deleted the Web View in IB, created a new one and linked it back up and now all is well. Go figure…