iOS data storage method:
plist (property list), preference (preference), SQLite, coredata
plist and preference do not support storage of custom models
How to organize the code to create a plist file:
#pragma mark - Create plist file-(void)creatPlistFileWithArr:(NSArray *)array{ //Save the dictionary to the document file -> Get the appdocument path NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; //The plist file name to be created -> path NSString *filePath = [docPath stringByAppendingPathComponent:@""]; //Write the array to the file [array writeToFile:filePath atomically:YES]; //Read the file NSArray *plistArr = [NSArray arrayWithContentsOfFile:filePath]; NSLog(@"Read the written plist file:%@",plistArr); }
The above article on iOS generating plist files and examples of creating plists in the project code are all the content I share with you. I hope you can give you a reference and I hope you can support me more.