简体   繁体   中英

iOS plist can't load data fom plist but works on simulator

-(NSString*)dataFilePath{        
    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [path objectAtIndex:0];

    return [documentDirectory stringByAppendingPathComponent:@"ProperyList.plist"];
}

The iDevice can't load data form this path, only the simulator can.

First of all, NSLog your dataFilePath value returned from this method and then check either the plist file (PropertyList.plist) exists at your document directory or not. Use the following code to check this :

NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL success = [fileManager fileExistsAtPath:dataFilePath];

You must also confirm whether you are you using the correct file name. iOS devices are case sensitive while simulator is not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM