开发者

How do I specify to only display the "Value" of my plist - Right now the whole path loads in my UITextfield

开发者 https://www.devze.com 2022-12-24 10:53 出处:网络
showDescriptionPath is being passed from the previous Tableview.The text shows up, but the entire path prints in the UITextField instead of just the value of \"Description\" in my plist.

showDescriptionPath is being passed from the previous Tableview. The text shows up, but the entire path prints in the UITextField instead of just the value of "Description" in my plist.

NSString *DescriptionPath = [[NSBundle mainBundle] bundlePath];
NSString *DescriptionInfoPath = [DescriptionPath stringByAppendingPathComponent:showDescriptionInfo];
showDescription.text = [[NSStri开发者_C百科ng alloc] initWithFormat:@"%@",DescriptionInfoPath];


That's because you're not trying to load a value at all. The code you posted above will only show the path of what you're trying to load.

You can init a dictionary and get a value by using:

NSDictionary * myDict = [[NSDictionary alloc] initWithContentsOfFile:DescriptionInfoPath];
NSString * theValue = [myDict valueForKey:@"theKey"];
showDescription.text = theValue;
[myDict release];

Hope that helps

0

精彩评论

暂无评论...
验证码 换一张
取 消