0
我在iPhone應用程序implemanting包含一些初始參數,我將在後面的應用程序,我創建了一個NSMutableArray的myArray的一個的NSMutableDictionary一些按鍵使用的.plist文件,然後我創建文件:如何在運行時從iPhone中的文檔目錄讀取數據?
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingString:@"Initial.plist"];
[myArray writeToFile:filePath atomically:YES];
我acccess這個文件的內容:
NSMutableArray *temp= [[NSMutableArray alloc]initWithContentsOfFile:filePath];
寄託都工作在模擬器罰款,但是當我在設備運行測試溫度的內容始終是空的,我沒有任何想法,爲什麼我得到一個無數組,也許我做錯了訪問該文件。
也許應該使用stringByAppendingPathComponent –