获取值
+ (id)valuePlist:(NSString *)plistName withKey:(NSString*)key;
编辑值,根据类型使用
//String
+(void)editStringPlist:(NSString *)plistName withKey:(NSString*)key andString:(NSString*)string;
//Number
+(void)editNumberPlist:(NSString *)plistName withKey:(NSString*)key andNumber:(NSNumber*)number;
//Bool
+(void)editBoolPlist:(NSString *)plistName withKey:(NSString*)key andBool:(BOOL)boolValue;
//Data
+(void)editDataPlist:(NSString *)plistName withKey:(NSString*)key andData:(NSData*)data;
//Date
+(void)editDatePlist:(NSString *)plistName withKey:(NSString*)key andDate:(NSDate*)date;
//Array
+(void)editArrayPlist:(NSString *)plistName withKey:(NSString*)key andArray:(NSArray*)array;
//Dictionary
+(void)editDictionaryPlist:(NSString *)plistName withKey:(NSString*)key andDictionary:(NSDictionary*)dictionary;
从项目中的'settings.plist'文件中获取背景音乐名称
NSString *stringFromPlist = [NRSimplePlist valuePlist:@"settings" withKey:@"backgroundMusic"];
编辑背景音乐,实时保存更改
//You can put this into a viewDidLoad method, a generic method, a class or where you need it!
[NRSimplePlist editStringPlist:@"settings" withKey:@"backgroundMusic" andString:@"bgMusic2.mp3"];
很简单,让我们试试吧!
注意:如果您想要保存敏感数据,请勿使用PLIST!改用CoreData或MySQL/MySQLi数据库!
使用
+ (id)valorePlist:(NSString *)nomeFile conChiave:(NSString*)chiave;
根据类型修改值,使用
//Stringa
+(void)modificaStringaPlist:(NSString *)nomeFile conChiave:(NSString*)chiave eStringa:(NSString*)stringa;
//Numero
+(void)modificaNumeroPlist:(NSString *)nomeFile conChiave:(NSString*)chiave eNumero:(NSNumber*)numero;
//Bool
+(void)modificaBoolPlist:(NSString *)nomeFile conChiave:(NSString*)chiave eBool:(BOOL)valoreBooleano;
//Data
+(void)modificaDataPlist:(NSString *)nomeFile conChiave:(NSString*)chiave eData:(NSData*)data;
//Date
+(void)modificaDatePlist:(NSString *)nomeFile conChiave:(NSString*)chiave eDate:(NSDate*)date;
//Array
+(void)modificaArrayPlist:(NSString *)nomeFile conChiave:(NSString*)chiave eArray:(NSArray*)array;
//Dictionary
+(void)modificaDictionaryPlist:(NSString *)nomeFile conChiave:(NSString*)chiave eDictionary:(NSDictionary*)dictionary;
从项目中的'setttaggi.plist'文件中提取背景音乐名称
NSString *stringaDaPlist = [NRSimplePlist valorePlist:@"settaggi" conChiave:@"musicaSottofondo"];
现在编辑背景音乐,立即保存更改
[NRSimplePlist modificaStringaPlist:@"settaggi" conChiave:@"musicaSottofondo" eStringa:@"sottofondo2.mp3"];
很简单吧?也试试看吧!
注意:如果您需要传递敏感数据,请勿使用PLIST!改用CoreData或MySQL或MySQLi数据库!