Re: PDFView setDocument: autorelease crash?
Re: PDFView setDocument: autorelease crash?
- Subject: Re: PDFView setDocument: autorelease crash?
- From: Brian Ganninger <email@hidden>
- Date: Sun, 11 Mar 2007 22:04:19 -0500
On Mar 11, 2007, at 8:23 PM, Chris Ryland wrote:
On Mar 10, 2007, at 9:52 AM, Keith Blount wrote:
(void)loadPDFDocumentFromFile:(NSString *)filePath
{
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:fileURL];
[pdfView setDocument:pdfDoc];
}
The crashes go away, but this just does not seem right. The docs
say that -setDocument: releases the current PDFDocument before
loading the new one, so I would have thought that it would retain
the newly loaded document, but these crashes seem to indicate,
strangely, that it does not.
Is this a bug in PDFView, or have I missed something obvious?
I'm a Cocoa relative newcomer, but I thought the general pattern
was that
[[AnyClass alloc] initWithSomeKindOfArg: arg]
returned an object already auto-released.
Other way round - any alloc/init pair (or a copy'ed object) is a
retained object you'll need to release on your own. Any object from a
class method (stringWithString:, dateWithNaturalLanguageString:,
array, dictionary, etc.) returns an auto-released object.
- brian 'bgannin' ganninger
Cheers!
--Chris Ryland / Em Software, Inc. / www.emsoftware.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden