Re: Add metadata to my files for Spotlight
Re: Add metadata to my files for Spotlight
- Subject: Re: Add metadata to my files for Spotlight
- From: Ondra Cada <email@hidden>
- Date: Thu, 12 May 2005 00:25:25 +0200
Lorenzo,
On 11.5.2005, at 15:05, Lorenzo wrote:
Jonathon, what you say is what I thought indeed. But Scott
suggested to
don't do so. In that Apple sample I have found:
pool = [[NSAutoreleasePool alloc] init];
tempDict = [[NSDictionary alloc]
initWithContentsOfFile:(NSString*)pathToFile];
//....
[tempDict release];
[pool release];
return success;
Don't. The pattern
pool=[[NSAutoreleasePool alloc] init];
tempDict=[NSDictionary dictionaryWith...];
...
[pool release];
return success;
is as efficient as the above one, and it is *considerably* more
failsafe (like, that it does not leak if it happens to raise an
exception in the middle, and of course also that it is not vulnerable
to you messing up the allocs/release pairing).
There may be some point in avoiding autoreleasing in some cases, but
self-evidently this is not one of them. My pet rule of thumb is:
either you know darn well why you are avoiding the pool -- or, if
not, you are making a mistake doing so.
I use this method in my applications and it always works well.
So, now I am confused, what do I have to do in the importer?
None of the patterns is wrong per se, both would work well normally.
The one of yours is more prone to problems though.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden