On Apr 3, 2008, at 9:52 PM, Chris Suter wrote:

You're releasing things you shouldn't be. Take some time to read the memory management documentation.

well, exactly

so here is what I have

NSString *nsFontName = [NSString stringWithCString:fontName encoding:NSMacOSRomanStringEncoding]; NSString *textString = [NSString stringWithCString:"Hello From Cocoa" encoding:NSMacOSRomanStringEncoding]; NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:TRUE]; NSColor *cocoaColor = [NSColor colorWithCalibratedRed:r green:g blue:b alpha:alpha];
        NSFont *font = [NSFont fontWithName:nsFontName size:fontSize];
NSMutableDictionary *stringAttributes = [NSMutableDictionary dictionaryWithCapacity:4];


documentation for
+[NSString stringWithCString:encoding ] no word about releasing / retaining

+[NSGraphicsContext graphicsContextWithGraphicsPort: flipped:]
it says "Return Value: The created NSGraphicsContext object or nil if the object could not be created."
so I suppose I should release it

+[NSColor colorWithCalibratedRed:green:blue:alpha]; no word about releasing / retaining it says: "Return Value The color object." so I suppose I should release it, because it returns new object

+[NSFont fontWithName: size:fontSize];
from documenattion
"Return Value
A font object for the specified name and size.
Discussion
The fontName is a fully specified family-face name, such as Helvetica- BoldOblique or Times-Roman. The fontSize is equivalent to using a font matrix of [fontSize 0 0 fontSize 0 0] withfontWithDescriptor:size:. If you use a fontSize of 0.0, this method uses the default User Font size. Fonts created with this method automatically flip themselves in flipped views. This method is the preferred means for creating fonts."
so it said "created" so I thought I should release it

and finally

+[NSMutableDictionary dictionaryWithCapacity]
Return Value
A new mutable dictionary with enough allocated memory to hold numItems entries.
it says "NEW" so I suppose I should release it

I just thought that all those 5 methods are CREATION methods they are not GET methods
so how do I know which one I should release?

after playing with those releases I found that only
        [font release];
        [nsFontName release];
are harmless

it looks like that they were cached

it doesn't make any sense to me (at least yet :-(   )

it looks like that solution is to go to GarbageCollection and forget about
pools/release e.t.c
that's what Apple wants? :-))

Dmitry Markman

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to