If you use convenience methods (as in the else branch) it is autoreleased. See here for details: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/ObjectOwnership.html#//apple_ref/doc/uid/20000043
On Thu, Mar 13, 2008 at 8:19 AM, 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/minustheben%40gmail.com > > This email sent to [EMAIL PROTECTED] > -- Ben Hatfield [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]