Re: Initializing Subclass of NSTextContainer
Re: Initializing Subclass of NSTextContainer
- Subject: Re: Initializing Subclass of NSTextContainer
- From: Shawn Erickson <email@hidden>
- Date: Tue, 30 Jan 2007 21:49:14 -0800
On Jan 29, 2007, at 2:53 PM, Gordon Apple wrote:
EDDynamicArray was originally a subclass of NSMutableData, but I then
changed it to subclass NSObject and to contain an NSMutableData
object,
which didn't help. In the subview of NSTextView in AwakeFromNib, I
replace
the text container. (This has worked before.)
In this case, when run, the [EDDynamicArray alloc] appears to
generate a
log message saying:
2007-01-29 16:41:29.676 DocBooker[12196] *** -[EDDynamicArray
textView]:
selector not recognized [self = 0x37a570]
That sounds like a call is not matching up with what I am
trying to
call. How could "alloc" be going wrong? What else could be
happening?
You don't show us how you allocate the NSMutableData instance. Likely
you are creating it in such a way that you don't take ownership of it
and hence it gets deallocated out from under you. If that happens you
are left with a pointer to random memory... memory that could contain
an unrelated object sometime in the future.
Ahhh from you second email...
I create it with [NSMutableData dataWithCapacity:256] which is
supposed to return a new NSMutableData object.
I suspect my guess was correct... you should review the memory
management rules of Cocoa to better understand why things are going
wrong. Make sure to review the Object Ownership and Disposal section
of the following ... in particular the part about using convenience
methods.
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
index.html>
-Shawn
_______________________________________________
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