Как избежать пула автоматического выпуска в моем AppDelegate в моем окне выбора.Когда я нажимаю кнопку с именем «электронная почта», происходит сбой моей программы.
Вот мой фрагмент кода:
-(void)pickerViewEmail:(UIPickerView *)pickerViewEmail didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if ([[musicList objectAtIndex:row] isEqual:@"m1"])
{
MFMailComposeViewController *pickerEmail = [[MFMailComposeViewController alloc] init];
pickerEmail.mailComposeDelegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@"m1" ofType:@"mp3"];
NSData *m1 = [NSData dataWithContentsOfFile:path];
[pickerEmail addAttachmentData:m1 mimeType:@"audio/mp3" fileName:@"m1"];
[pickerEmail setSubject:@"Hello"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com",
[pickerEmail setToRecipients:toRecipients];
[pickerEmail setCcRecipients:ccRecipients];
// Fill out the email body text
NSString *emailBody = @"Hello";
[pickerEmail setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:pickerEmail animated:YES];
[pickerEmail release];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
message.hidden = NO;
switch (result)
{
case MFMailComposeResultCancelled:
message.text = @"Email canceled";
break;
case MFMailComposeResultSaved:
message.text = @"Email saved";
break;
case MFMailComposeResultSent:
message.text = @"Email sent";
break;
case MFMailComposeResultFailed:
message.text = @"Email failed";
break;
default:
message.text = @"Email not sent";
break;
}
[self dismissModalViewControllerAnimated:YES];
}
-(IBAction)showEmail
{
if ([MFMailComposeViewController canSendMail])
{
self.emailButton.enabled = YES ;
[self performSelector:@selector(pickerViewEmail:didSelectRow:inComponent:)
withObject:audioPlayer];
}
else
{
NSString *recipients = @"mailto:first@example.com?cc=second@example.com,third@example.com&subject=Hello!";
NSString *body = @"&body=Hello";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
}
Когда я нажимаю эту кнопку IBAction, программа отображает эту ошибку кода строки.
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Как избежать этого?
Вот мой вывод консоли:
[Switching to process 4452 thread 0x1f03]
[Switching to process 4452 thread 0x207]
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
0x0026f97f <+0891> mov %eax,(%esp)
0x0026f982 <+0894> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026f987 <+0899> mov %eax,%esi
0x0026f989 <+0901> mov 0x69940e(%edi),%eax
0x0026f98f <+0907> mov 0x68db46(%edi),%ecx
0x0026f995 <+0913> lea 0x525009(%edi),%edx
0x0026f99b <+0919> mov %edx,0x8(%esp)
0x0026f99f <+0923> mov %ecx,0x4(%esp)
0x0026f9a3 <+0927> mov %eax,(%esp)
0x0026f9a6 <+0930> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026f9ab <+0935> mov 0x68df86(%edi),%ecx
0x0026f9b1 <+0941> mov %ebx,0x18(%esp)
0x0026f9b5 <+0945> lea 0x6a6c56(%edi),%edx
0x0026f9bb <+0951> mov %edx,0x14(%esp)
0x0026f9bf <+0955> mov %eax,0xc(%esp)
0x0026f9c3 <+0959> mov %esi,0x8(%esp)
0x0026f9c7 <+0963> mov %ecx,0x4(%esp)
0x0026f9cb <+0967> mov -0x18(%ebp),%eax
0x0026f9ce <+0970> mov %eax,(%esp)
0x0026f9d1 <+0973> movl $0x641,0x10(%esp)
0x0026f9d9 <+0981> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026f9de <+0986> mov 0x699476(%edi),%eax
0x0026f9e4 <+0992> mov 0x68db72(%edi),%ecx
0x0026f9ea <+0998> mov %ecx,0x4(%esp)
0x0026f9ee <+1002> mov %eax,(%esp)
0x0026f9f1 <+1005> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026f9f6 <+1010> mov 0x68df92(%edi),%ecx
0x0026f9fc <+1016> mov %eax,0x8(%esp)
0x0026fa00 <+1020> mov %ecx,0x4(%esp)
0x0026fa04 <+1024> mov -0x10(%ebp),%esi
0x0026fa07 <+1027> mov %esi,(%esp)
0x0026fa0a <+1030> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026fa0f <+1035> mov 0x6d0fbe(%edi),%ebx
0x0026fa15 <+1041> test %al,%al
0x0026fa17 <+1043> je 0x26fa2c <UIApplicationMain+1064>
0x0026fa19 <+1045> mov 0x68dbb6(%edi),%eax
0x0026fa1f <+1051> mov %ebx,0x8(%esp)
0x0026fa23 <+1055> mov %eax,0x4(%esp)
0x0026fa27 <+1059> mov %ebx,(%esp)
0x0026fa2a <+1062> jmp 0x26fa69 <UIApplicationMain+1125>
0x0026fa2c <+1064> mov 0x68dc0a(%edi),%eax
0x0026fa32 <+1070> mov %eax,0x4(%esp)
0x0026fa36 <+1074> mov %esi,(%esp)
0x0026fa39 <+1077> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026fa3e <+1082> mov 0x68dcba(%edi),%ecx
0x0026fa44 <+1088> mov %ecx,0x4(%esp)
0x0026fa48 <+1092> mov %eax,(%esp)
0x0026fa4b <+1095> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026fa50 <+1100> mov 0x68df96(%edi),%ecx
0x0026fa56 <+1106> mov %eax,0x8(%esp)
0x0026fa5a <+1110> mov %ecx,0x4(%esp)
0x0026fa5e <+1114> mov %ebx,(%esp)
0x0026fa61 <+1117> movl $0x1,0xc(%esp)
0x0026fa69 <+1125> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026fa6e <+1130> mov 0x68db22(%edi),%eax
0x0026fa74 <+1136> mov %eax,0x4(%esp)
0x0026fa78 <+1140> mov -0x14(%ebp),%eax
0x0026fa7b <+1143> mov %eax,(%esp)
0x0026fa7e <+1146> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026fa83 <+1151> mov 0x6d0fbe(%edi),%eax
0x0026fa89 <+1157> mov 0x68df9a(%edi),%ecx
0x0026fa8f <+1163> mov %ecx,0x4(%esp)
0x0026fa93 <+1167> mov %eax,(%esp)
0x0026fa96 <+1170> call 0x70a8b2 <dyld_stub_objc_msgSend>
0x0026fa9b <+1175> xor %eax,%eax
0x0026fa9d <+1177> add $0x2c,%esp
0x0026faa0 <+1180> pop %esi
0x0026faa1 <+1181> pop %edi
0x0026faa2 <+1182> pop %ebx
0x0026faa3 <+1183> pop %ebp
0x0026faa4 <+1184> ret
Эта строка вызывает сбой - (void) mailComposeController: (MFMailComposeViewController*) контроллер didFinishWithResult: (MFMailComposeResult) ошибка результата: (NSError *) ошибка