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]);
我使用此代碼,並要釋放的NSString * .. 所以,我宣佈文件名,FULLPATH和的NSString的databasePath。 數據庫已發佈但文件名,完整路徑未發佈。我不知道爲什麼會發生。如何釋放的NSString
我知道的NSArray會被自動釋放。但是文檔目錄autoreleased? (newWordbookName是NSString的類型)
我希望通過一個關於iPhone的內存管理文件的樣子。