2012-01-08 5 views
-2

내 피커 뷰에서 내 AppDelegate의 자동 풀이 발생하지 않도록하는 방법. 전자 메일이라는 버튼을 클릭하면 프로그램이 중단됩니다.iOS : 피커 뷰에서 MFMailComposeViewController를 사용하여 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:@"[email protected]"]; 
     NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", 

     [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:[email protected][email protected],[email protected]&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])); 
    } 
} 

이 문제를 방지하려면 어떻게해야합니까? (MFMailComposeViewController *) 컨트롤러 didFinishWithResult : (MFMailComposeResult) 결과 오류 (NSError *) 오류

- (공극) mailComposeController

[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  

이 광고가 충돌 일으키는 : 여기

내 콘솔 출력
+0

어떻게 이것이 자동 풀링 문제인지 알고 계십니까? 귀하의 코드 또는 귀하의 eeyy 대나무 로그 출력 스 니펫에 autorelease라는 단어가 표시되지 않습니다. –

+0

어떤 코드 줄에서 충돌이 발생합니까? – user1118321

+0

코드 줄은 위에 있습니다. 여기 : return UIApplicationMain (argc, argv, nil, NSStringFromClass ([AppDelegate class])); – Amink

답변

0

디버거/스택 추적에서 아무런 도움이되지 않는 것처럼 보입니다. 오류의 위치와 위치를 파악할 수있는 또 다른 방법이 있습니다.

는 충돌 때까지 선으로 코드 라인을 통해 단계

-(void)pickerViewEmail:(UIPickerView *)pickerViewEmail didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 

// PUT BREAKPOINT HERE 

if ([[musicList objectAtIndex:row] isEqual:@"m1"]) 
... 

에 중단 점을 넣습니다.

일단 수정했다면 질문을 수정하고 충돌을 일으키는 라인을 알려주십시오.

+0

이 줄이 충돌을 일으키고 있습니다. - (void) mailComposeController : (MFMailComposeViewController *) 컨트롤러 didFinishWithResult : (MFMailComposeResult) 결과 오류 : (NSError *) 오류 – Amink

+0

Ok. 피커보기에 대해 선택한 6 개의 전자 메일 단추를 수동으로 입력하면 올바르게 작동합니다. – Amink

+0

마지막 의견을 이해할 수 없습니다. ('6을 의미합니까? ') – deanWombourne