我在xcode中有一个名为“config.plist”的plist,我试图检索寄存器url(键:reg),但是当我打印该结果时,它显示空值?

这是我检索字符串的代码。请为我的plist结构引用图像。

NSMutableURLRequest *request =[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString: [[_config objectForKey:@"URL"] objectForKey:@"reg"]]];

最佳答案

试试这个代码

NSString *plistFilePath=[[NSBundle mainBundle] pathForResource:@"config" ofType:@"plist"];
NSDictionary *urlDictionary=[[NSDictionary alloc] initWithContentsOfFile:plistFilePath];
NSString *urlString=[[urlDictionary objectForKey:@"URL"] valueForKey:@"reg"];

10-08 05:52