我在 NSDictionary 中提取和更改值有问题。
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"dictRecensiti"];
NSLog(@"dict %@",dict);
这是输出:
dict (
(
{
ingredientiRecensito = "AQUA,CETYL%20PALMITATE,PROPYLENE%20GLYCOL,SORBITOL,PRUNUS%20DULCIS,ISODODECANE,STEARIC%20ACID,CETYL%20ALCOHOL,LANOLIN,CYCLOPENTASILOXANE,CALENDULA%20OFFICINALIS,SQUALANE,HEXYLENE%20GLYCOL,FRUCTOSE,GLUCOSE,SUCROSE,UREA,DEXTRIN,ALANINE,GLUTAMIC%20ACID,ASPARTIC%20ACID,HEXYL%20NICOTINATE,TRIETHANOLAMINE,OCTYL%20METHOXYCINNAMATE,OCTYL%20COCOATE,BISABOLOL,CARBOMER,PHENOXYETHANOL,METHYLPARABEN,BUTYLPARABEN,ETHYLPARABEN,PROPYLPARABEN,SEBACIC%20ACID,CI%2047000,CI%2061565,GLYCERYL%20LINOLEATE,GLYCERYL%20LINOLENATE,BUTYLENE%20GLYCOL,ENTEROMORPHA%20COMPRESSA%20EXTRACT,ALLANTOIN,SODIUM%20METHYLPARABEN,SODIUM%20BUTYLPARABEN,SODIUM%20ETHYLPARABEN,SODIUM%20PROPYLPARABEN,HYALURONIC%20ACID,BHT,PARFUM";
nomeRecensito = "Levissime%20Crema%20idratante%20pelli%20sensibili";
testoRecensito = "Massimomosmaomomaodmosmodmasoosaocaoaomcoasocmosamomaodm.%20Dmosadmoasmdomasd.%20Sdoamdoamodsmao";
tipoRecensito = "Crema%20viso%20pelli%20Sensibili";
}
),
{
ingredientiRecensito = "WATER,GLYCERIN,PEG-7%20GLYCERYL%20COCOATE,DISODIUM%20LAURETH%20SULFOSUCCINATE,SODIUM%20COCOAMPHOACETATE,PEG-25%20HYDROGENATED%20CASTOR%20OIL,CETEARETH-60%20MYRISTYL%20GLYCOL,PEG-200%20HYDROGENATED%20GLYCERYL%20PALMATE,LAURETH-3,COCO-GLUCOSIDE,AQUAPHILUS%20DOLOMIAE%20EXTRACT,ARGININE,CAPRYLYL%20GLYCOL,CITRIC%20ACID,EVENING%20PRIMROSE%20OIL/PALM%20OIL%20AMINOPROPANEDIOL%20ESTERS,GLYCINE,OENOTHERA%20BIENNIS%20OIL,SORBIC%20ACID,TOCOPHEROL";
nomeRecensito = "Avene%20XeraCalm%20A.D.%20olio%20detergente%20liporestitutivo";
testoRecensito = Blblblbnnn;
tipoRecensito = "Olio%20detergente";
}
)
现在我想替换 %20 ,所以我写道:
NSString *stringV = [dict valueForKey:@"ingredientiRecensito"];
stringV = [stringV stringByReplacingOccurrencesOfString:@"%20" withString:@" "];
NSLog(@"%@",stringV);
应用程序崩溃,这是输出:
[__NSArrayI stringByReplacingOccurrencesOfString:withString:]: unrecognized selector sent to instance 0xc90f360
提前致谢
编辑:我知道这不是采用此 nsuserdefault 的最佳解决方案,因此我试图从根本上更改代码以从此 nsuserdefault 获得另一种类型的输出。非常感谢