According to Andy Lee:

> On May 11, 2009, at 10:15 PM, jon wrote:
> > my wild guess right now is to do this below when ever i have the  
> > "NSString" instance assignment to prevent, for instance, "theTitle"  
> > from "randomly disappearing"...
> 
> I hope the following doesn't sound harsh, because I'm not trying to  
> be...
> 
> I'd second Clark's advice to read the docs on memory management, and  
> come back with specific questions if you have any.  And I'd add that  
> "randomly disappearing" is almost meaningless and gives us nothing to  
> go on.

Maybe I'm just psychic, or it could be because I made a bunch of
newby mistakes 2-3 months ago, but it doesn't sound meaningless to
me.

An object is there and valid, another method and it is still valid,
another breakpoint and still valid, next breakpoint it is junk.  At
least in managed memory (all I've used for Cocoa), it is a pretty
standard behaviour for a temporary object that is being kept but
not retained.


> > I do know that "NSSTring" is "different" than other objects,
> 
> What do you mean by this?  How do you know this?

To the newcomer it can certainly seem different, at least until the
mechanisms get clear in the head.

For me, I read the memory management stuff (or *some* memory
management stuff) and thought I understood the semantics of it.
What I missed is that the semantics don't matter.  The NSString
stringBy... methods clearly create new strings, so I followed up
by releasing them.  Obviously that explodes.  So I concluded they
were special and didn't do any memory operations on them.  Those
went boom at some time later, often many loops later, whenever I
used the containing object next.

What I didn't get is that it doesn't matter if the method creates,
allocates, etc.  It matters if the method name starts with "alloc,"
"create," etc.


-- 
Drew Lawson            |  Pass the tea and sympathy
                       |    for he good old days are dead
                       |  Let's raise a toast to those
                       |    who best survived the life they led
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to