我在这里找到了一个代码片段,我想使用它,但我不知道如何让它回到“字符串”并查看它是否有效......
// some strings for test
NSString *cpu = [[NSString alloc] initWithFormat:@"%.0f", [_cpuSlider value]];
NSString *ram = [[NSString alloc] initWithFormat:@"%.0f", [_ramSlider value]];
NSString *hdd = [[NSString alloc] initWithFormat:@"%.0f", [_hddSlider value]];
// put them into dictionary
NSDictionary *test = [NSDictionary dictionaryWithObjectsAndKeys:cpu, @"CPU", ram, @"RAM", hdd, @"HDD", nil];
// start of the code from page above
NSMutableData *myData = [[NSMutableData alloc]init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]initForWritingWithMutableData:myData];
[archiver encodeObject:test forKey:@"MyKEY"];
[archiver finishEncoding];
id testJson = [NSJSONSerialization JSONObjectWithData:myData options:0 error:nil];
// end of code
// HERE I'd like know what to put in to see it as a string..e.g. { "CPU"=value; etc...}
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"MLIA" message:????? delegate:nil cancelButtonTitle:@"Zavřít" otherButtonTitles: nil];
[av show];
非常感谢!