我是Iphone编程的新手。我的数据存储UIlabel以及属性。对于Exp,Text,TextColor,背景颜色等。现在我想在电子邮件正文中发送所有数组数据。 这是我的代码。
NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
NSData *myDecodedObject = [userDefault objectForKey: [NSString
stringWithFormat:@"sample"]];
NSArray *arr= [[NSArray alloc] init];
arr= [NSKeyedUnarchiver unarchiveObjectWithData:myDecodedObject];
NSString *string = [arr componentsJoinedByString:@"\n"];
NSString *emailBody = string;
NSLog(@"Testing %@", string);
[mailer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailer animated:YES];
[mailer release];
我的数组显示存储在其中的所有对象并显示bytes.At这次我的数组包含5个UIlabel。现在我想在电子邮件正文中发送所有这些UIlabel。但NSLog我看到了这一点。
测试UILabel:0x8123760; frame =(135.5 136; 99 30); text ='Fddddddddddddddd ... clipsToBounds = YES; hidden = YES; layer = CALayer:0x8161590
UILabel:0x81619b0; frame =(148 323; 69 15); text ='Xxxxxxxxxxx'; clipsToBounds = YES; layer = CALayer:0x8161a50
UILabel:0x8161b70; frame =(140 341; 56 19); text ='Xxxxxxx'; clipsToBounds = YES; layer = CALayer:0x81618f0
UILabel:0x8161d70; frame =(69.5 121.5; 99 145); text ='Fddddddddddddddd ... clipsToBounds = YES; hidden = YES; layer = CALayer:0x8161e00
UILabel:0x8161f10; frame =(108 321; 99 145); text ='Fddddddddddddddd ... clipsToBounds = YES; layer = CALayer:0x8161f80
未在E-mail中看到任何数据。请建议什么是在电子邮件中发送数组数据的最佳方法.Thanx
答案 0 :(得分:0)
useMFmailComposer的addDataAttachements方法用于添加数组
中的数据 NSData *data = [NSKeyedArchiver archivedDataWithRootObject:arr1];
NSLog(@"Testing %@", data);
[controller addAttachmentData:data mimeType:@"application/octet-stream";
fileName:nil]