Xcode 将MFMailComposeViewController的NSDictionary数组值转换为NSString格式

Xcode 将MFMailComposeViewController的NSDictionary数组值转换为NSString格式,xcode,nsstring,formatting,nsdictionary,picker,Xcode,Nsstring,Formatting,Nsdictionary,Picker,我有一个UIPickerViewDelegate,它允许用户从选择器中选择一个术语,并通过使用NSDictionary访问plist文件中存储的数据来查看术语的定义。我还有一个MFMailComposeViewController,允许用户通过电子邮件将术语及其定义发送到其他地方 但我似乎无法将术语和定义正确格式化,以便输入电子邮件。我查看了各种“将NSDictionary转换为NSString”解决方案,但似乎都没有提供我需要的解决方案,包括Term=[dict objectForKey:@“

我有一个UIPickerViewDelegate,它允许用户从选择器中选择一个术语,并通过使用NSDictionary访问plist文件中存储的数据来查看术语的定义。我还有一个MFMailComposeViewController,允许用户通过电子邮件将术语及其定义发送到其他地方

但我似乎无法将术语和定义正确格式化,以便输入电子邮件。我查看了各种“将NSDictionary转换为NSString”解决方案,但似乎都没有提供我需要的解决方案,包括
Term=[dict objectForKey:@“Term”]
的变体

在viewDidLoad下,我有以下内容:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Glossary" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
self.termArray = [dict objectForKey:@"Term"];
self.definitionArray = [dict objectForKey:@"Definition"];
我的pickerView代码包括:

NSString *resultString = [[NSString alloc] initWithFormat:
                          @"%@",
                          [definitionArray objectAtIndex:row]];
definitionLabel.text = resultString;
NSString *termString = [[NSString alloc] initWithFormat:
                          @"%@",
                          [termArray objectAtIndex:row]];
showEmail的代码包含:

int definitionIndex = [self.termPicker selectedRowInComponent:0];
NSString *emailTitle = [NSString stringWithFormat:@"Definition of %@", termLabel];
NSString *emailDefinition = [definitionArray objectAtIndex:definitionIndex];
NSString *messageBody = [NSString stringWithFormat:@"The definition of <B>%@</B> is:<P> <B>%@</B>", termLabel, emailDefinition];

MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:YES];
int definitionIndex=[self.termPicker selectedRowUncomponent:0];
NSString*emailTitle=[NSString stringWithFormat:@“定义%@”,术语标签];
NSString*emailDefinition=[definitionArray objectAtIndex:definitionIndex];
NSString*messageBody=[NSString stringWithFormat:@“%@的定义是:

%@”,术语标签,电子邮件定义]; MFMailComposeViewController*mc=[[MFMailComposeViewController alloc]init]; mc.mailComposeDelegate=self; [mc设置主题:emailTitle]; [mc setMessageBody:messageBody isHTML:YES];


我希望电子邮件标题和邮件正文从选择器中选择的术语以及与之相关的定义中提取。我确信这一定是一个简单的格式问题,但我想不出来。

好的。我得到了一半的工作定义(代码更新以上)。但是,如文中所述,该术语显示为“(空)”。再说一遍,我想这只是一个格式问题?有人吗?问题可能在于,我所期望的代码将接受选择器选择并将其放入术语字段,而不是删除定义。因此,我不确定如何检索实际的选择器选择,因为应用程序认为结果实际上是链接到选择器中所选内容的定义。