Re: Strange printing issue
Re: Strange printing issue
- Subject: Re: Strange printing issue
- From: Tom Bernard <email@hidden>
- Date: Wed, 07 Jul 2004 16:09:00 -0600
Hi Andrew,
In my last note to you, I forgot to point out that you mistakenly release
printInfo. You need to release objects that you created with alloc; you do
not release objects that you did not create. If you receive an object from a
class method of another class (in this case, +[NSPrintInfo
sharedPrintInfo]), that method has already autoreleased the object. When you
also release the object, the object receives too many release messages. The
last release message will be sent after the object has been deallocated and
your app crashes.
Regards,
Tom Bernard
email@hidden
- (void)printReceipt:(Transaction *)transToPrint
{
NSPrintOperation *op;
NSRect rect = [self printAreaInScaledPaperCoordinates];
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
// NSFont *font = [NSFont userFixedPitchFontOfSize:10.0];
[printInfo setLeftMargin:0.0];
[printInfo setRightMargin:0.0];
[printInfo setBottomMargin:0.25];
NSTextView *view = [[NSTextView alloc] initWithFrame:rect];
// [view setFont:font];
[view insertText:[transToPrint description]];
op = [NSPrintOperation printOperationWithView:view];
[op setShowPanels:NO];
[op runOperation];
[view release];
[printInfo release];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.