I don't know How to release NSString.

Posted by Beomseok on Stack Overflow See other posts from Stack Overflow or by Beomseok
Published on 2010-04-03T19:28:01Z Indexed on 2010/04/03 19:33 UTC
Read the original article Hit count: 362

Filed under:
|
|
NSArray     *path                   = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString    *documentsDirectory     = [path objectAtIndex:0];

    NSString    *databasePath           = [documentsDirectory stringByAppendingPathComponent:@"DB"];
    NSString    *fileName               = [newWordbookName stringByAppendingString:@".csv"];
    NSString    *fullPath               = [databasePath stringByAppendingPathComponent:fileName];

    [[NSFileManager defaultManager] createFileAtPath:fullPath contents:nil attributes:nil]; 

    [databasePath release];
    //[fileName release]; Error!
    //[fullPath release]; Error!

    //NSLog(@"#1 :databasePath: %d",[databasePath retainCount]);
    //NSLog(@"#1 :fileName: %d",[fileName retainCount]);
    //NSLog(@"#1 :fullPath: %d",[fullPath retainCount]);

Hi guys, I'm using this code and want to release NSString* .. so, I declare fileName, fullPath, and databasePath of NSString. But database is released, fileName, fullpath doen't release. I don't know why it happen.

I know that NSArray is Autoreleased. But Is documentsDirectory autoreleased? (newWordbookName is nsstring type)

I hope that I look through a document about iPhone memory management. Please advice for me.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsstring