NSUserDefaults:倾销NSUserDefaults的standardUserDefaults的结构 [英] NSUserDefaults: Dumping the structure of NSUserDefaults's standardUserDefaults
问题描述
有没有人知道通过NSLog转储NSUserDefaults的standardUserDefaults的快速方法?这是我有:
Does anyone know of a quick way to dump the standardUserDefaults of NSUserDefaults via NSLog? This is what I have:
NSLog(@"NSUserDefaults dump: %@", [NSUserDefaults standardUserDefaults]);
但它返回:
NSUserDefaults dump: <NSUserDefaults: 0x50b520>
...这不是我想要的。我真的很想要键 - 值对。
...which is not quite what I'm looking for. I'd really like to have key-value pairs.
任何帮助或一个正确的方向的一个点将非常感谢。干杯!
Any help or a point in the right direction would be greatly appreciated. Cheers!
推荐答案
感谢Don McCaughey,我的业务伙伴和朋友,为我修正我的代码, 。要与其他人分享此代码片段:
Thanks to Don McCaughey, my business partner and friend, for fixing up my code for me and supply a concise answer. To share it with the rest of you here is a code snippet:
NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary];
NSString *bundleId = [bundleInfo objectForKey: @"CFBundleIdentifier"];
NSUserDefaults *appUserDefaults = [[NSUserDefaults alloc] init];
NSLog(@"Start dumping userDefaults for %@", bundleId);
NSLog(@"userDefaults dump: %@", [appUserDefaults persistentDomainForName: bundleId]);
NSLog(@"Finished dumping userDefaults for %@", bundleId);
[appUserDefaults release];
正如你所看到的,每个回答问题的人都在正确的轨道上, up是解决方案 - 直到Don在源代码控制中编辑我们的代码。感谢所有!
As you can see, everyone who was answering the question was on the right track, but no code offered up was the solution - until Don's editing of our code in source control. Thanks All!
这篇关于NSUserDefaults:倾销NSUserDefaults的standardUserDefaults的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!