You are correct, [NSDictionary dictionaryWithContentsOfFile:indexFilePath] will return an autoreleased object, so you do not need to call [index release].
Take a look at this article: http://www.stepwise.com/Articles/Technical/HoldMe.html On 13/03/2008, Daniel Luis dos Santos <[EMAIL PROTECTED]> wrote: > Hello, > > I have the following code : > > if (![fileMgr fileExistsAtPath: indexFilePath]) { > NSMutableDictionary *index = [[NSMutableDictionary alloc] > init]; > [index setObject: [NSNumber numberWithLong: > DEFAULTS_BLOCKSIZE] > forKey: INDEXKEY_BLOCKSIZE]; > [index setObject: [NSNumber numberWithLong: > DEFAULTS_BLOCKSPERPAGE] > forKey: INDEXKEY_BLOCKSPERPAGE]; > _blockSize = DEFAULTS_BLOCKSIZE; > _blocksPerPage = DEFAULTS_BLOCKSPERPAGE; > if (![index writeToFile: indexFilePath atomically: YES]) { > _dirPath = nil; > NSLog(LOGMSG_INDEXFILENOTWRITABLE); > } > [index release]; > } else { > NSDictionary *index = [NSDictionary > dictionaryWithContentsOfFile: > indexFilePath]; > if (nil == [index objectForKey: INDEXKEY_BLOCKSIZE]) { > NSLog(LOGMSG_INDEXFILEOUTOFFORMAT); > _dirPath = nil; > } else > _blockSize = [(NSNumber*)[index objectForKey: > INDEXKEY_BLOCKSIZE] > longValue]; > if (nil == [index objectForKey: INDEXKEY_BLOCKSPERPAGE]) { > NSLog(LOGMSG_INDEXFILEOUTOFFORMAT); > _dirPath = nil; > } else > _blocksPerPage = [(NSNumber*)[index objectForKey: > INDEXKEY_BLOCKSPERPAGE] longValue]; > [index release]; > } > > the [index release] on the second branch gives me the following output > on the debugger window : > > TestRunnrer(1661) malloc: *** error for object 0x112a50: double free > *** set a breakpoint in malloc_error_break to debug > > in the enclosing scope I have set up an autorelease pool. What I am > suspecting is that when I init the dictionary with a file it is > autoreleased, and then the error when I do the release. I this the > case ? If so where do I know when some object is created autoreleased > or not ? In the NSDictionary's reference page there is nothing > mentioned. > > Many thanks > _______________________________________________ > > 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/c.holloway%40gmail.com > > This email sent to [EMAIL PROTECTED] > _______________________________________________ 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]