Odd memory issue -- not a newbie
Odd memory issue -- not a newbie
- Subject: Odd memory issue -- not a newbie
- From: Jonathan Jackel <email@hidden>
- Date: Sat, 13 Dec 2003 19:57:40 -0500
I'm printing a text view in a special way, so I use a custom view.
Mainly, I'm interested in the text view's text storage, because that's
what I want to print. I tried to write my setter this way:
- (void)setMyStorage:(NSTextStorage *)newStorage
{
[newStorage retain];
[myStorage release];
myStorage = newStorage;
}
When printing is done and my print view is released, it releases
myStorage in dealloc. This all seems pretty standard, and printing
works, but subsequent attempts to edit the text view or use its text
storage result in a crash.
If I do it this way everything works fine:
- (void)setMyStorage:(NSTextStorage *)newStorage
{
[myStorage autorelease];
myStorage = [[NSTextStorage alloc]
initWithAttributedString:newStorage];
}
I'd much rather do it the first way because I don't see the need to
make a copy of what could be a fairly massive attributed string. I'd
rather just retain the text storage, add a new layout manager and text
containers, print my view, then remove my layout manager and release
the text storage. But it doesn't work.
What am I doing wrong?
Jonathan
_______________________________________________
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.