2012-08-01 1 views
0

누구? 메일 구성 인터페이스는 문서에 기각하지 않을 때 열거 형에엑스 코드 4.4 경고 : 케이스 값이 아닙니다 열거 형에서 'MessageComposeResult'(일명 '열거 MessageComposeResult') 엑스 코드 4.4에서이 경고를 받고 다른

케이스 값 'MessageComposeResult'(일명 '열거 MessageComposeResult')

MFMailComposeResultFailed이 결과 코드에 포함되어 돌아왔다. 그러나 문서에 나열되어 있지만 GCC는 MessageComposeResult 내의 열거 형이 아니라고 경고합니다. 왜? 나는이 너희들을 위해 그것을 명확하게 희망

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result { 

UIAlertView *errormsg = nil; 
// Notifies users about errors associated with the interface 
switch (result) 
{ 
    case MFMailComposeResultCancelled: 
    { 
     //Do something, If you need to 
     NSString *msgtitle = @"Cancelled Mail"; 
     NSString *Bodymsg = @"Email Has been Cancelled by USER. You may continue to make modifications to the current attendance data at this point."; 
     errormsg = [[UIAlertView alloc] initWithTitle:msgtitle message:Bodymsg delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; 
    } 
     break; 
    case MFMailComposeResultSaved:{/*Do nothing at this point*/} 
     break; 
     //NOTE: MFMailComposeResultFailed is included in Result codes returned when the mail composition interface is dismissed. However the documentation lists it but the GCC warns it is NOT an enum within MessageComposeResult. May be an Apple Bug. 
    /*case MFMailComposeResultFailed:{ 
     NSString *title = @"Unable to Send Mail"; 
     NSString *msg = @"Failed:\nmessage was not saved or queued, possibly due to an error.\nCheck your mail sent or draft items."; 
     errormsg = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; 
    } 
     break; 
     */ 
    case MFMailComposeResultSent:{ 
     NSString *title = @"Mail Sent"; 
     NSString *msg = @"Attendance Email has been sent. Thank you."; 

     errormsg = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; 
     //clean up data 
     //code here irrelevant 
     //set a completed flag for sent email in system 

     //display Alert and dismiss the mail composer view here 
     UIAlertView *alertView = nil; 

     if (result) { 
      alertView = [[UIAlertView alloc] initWithTitle:@"AttendanceViewController: viewDidLoad" message:@"updateProgressOfClassInstance FAILED" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     } 
     if (alertView != nil) { 
      [alertView show]; 
     } 

    } 
     break; 
    default: 
     break; 
} 
//dismiss view and display any errors here. 
[self dismissModalViewControllerAnimated:YES]; 
if (errormsg != nil) { 
    [errormsg show]; 
} 

: 여기

case MFMailComposeResultFailed:{ 
     //do something here 
    } 
     break; 

이 경우는 (내가 경고를 해제하는이 열거를 주석 한)라고하는 확장 된 방법이다. 감사!

은 (UPDATE) 좋아, 내가 거기 몰랐어요 내 코드에 몇 가지 문제가 있었다. 나는 그 (것)들을 고치고 아래에 결과 올바른 스위치 설명이다.

switch (result) 
{ 
    case MessageComposeResultCancelled: 
    { 
     //Do something, If you need to! 
    } 
     break; 

    case MessageComposeResultFailed:{ 
     //Do something else, If you need to!! 
    } 
     break; 

    case MessageComposeResultSent:{ 
     //Do something user friendly, If you need to! 

    } 
     break; 

    default: 
     break; 
} 

무료 세계에서 계속 stackoverflow! 우와!

+0

스위치 문을 표시하도록 질문을 확장하고 모든 케이스/기본 부품. –

답변

0

당신은 오류 코드를 혼합한다. 결과 열거 형에는 작업하는 것으로 보이는 세 가지 값이 있습니다.

은 "MFMailComposeResultFailed"값이 대리자 메서드의 오차 내에서 반환이 deocumentation 페이지의 하단에

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 

봐 :

MFMailComposeViewController Class Reference 
+0

그게 정말 나 바보 덕분에 데이빗 H! 나는 명확성을 위해 문제를 수정하여 업데이트 할 것이다. –