2010-06-04 26 views
0

我作爲Iphone開發者工作5個月以來,但從未使用過NSfilemanager類。蘋果有文件,但我仍然沒有清除它的使用。我的問題是,有人可以告訴我(例如)如何以及何時使用NSfilemanager類?任何幫助將不勝感激。謝謝。使用NSFilemanager

回答

2

NSFileManager用於對文件執行讀寫操作,將文件保存到應用程序中。檢查指定文件是否存在於該位置。

NSFileManager *fileManager = [NSFileManager defaultManager]; 
// Get the path to the database in the application package 
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; 

// Check if the database has already been created in the users filesystem 
success = [fileManager fileExistsAtPath:databasePath]; 

這是檢查文件存在的示例。