On 12/12/2009, at 12:37 PM, Keith Blount wrote:

> NSDictionary *searchIndexesDeepCopy = [NSKeyedUnarchiver 
> unarchiveObjectWithData:[NSKeyedArchiver 
> archivedDataWithRootObject:searchIndexes]];
> 
> [NSThread detachNewThreadSelector:@selector(saveSearchIndexes:) toTarget:self 
> withObject:searchIndexesDeepCopy];


OK, but 'searchesIndexDeepCopy' (which becomes 'searchInfo') is not used in the 
thread as written, so why do this?


> - (void)saveSearchIndexes:(NSDictionary *)searchInfo
> {
>       [myXMLGeneratedData writeToURL:myUrl atomically:YES];
> }

Where does 'myXMLGeneratedData'  and 'myUrl' come from? If they are data 
members of the document (or whatever) you need to consider whether they could 
be mutated by the main thread. If you're gettin gthese out of 'searchInfo' in 
unshown code you should be OK.

If your app uses retain/release (not garbage collection), you also need to put 
an autorelease pool in there:

- (void)saveSearchIndexes:(NSDictionary *)searchInfo
{
    NSAutoreleasePool* pool = [NSAutoreleasePool new];  
    [myXMLGeneratedData writeToURL:myUrl atomically:YES];
    [pool drain];
}



--Graham


_______________________________________________

Cocoa-dev mailing list ([email protected])

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