Menu

MFMailComposeViewController and MFMessageComposeViewController Access Violation?

2016-02-05
2016-02-10
  • Benjamin garcia

    Benjamin garcia - 2016-02-05

    hello, I'm developing an ios app using DPF.IOS but when i try to use MFMailComposeViewController I get an Access Violation error, can you help me please ?
    my code :

    procedure SendSMS.TestProcessAnswerSMSSend;
    {$IFDEF IOS}
    var
      lo_controller: MFMailComposeViewController;
      lo_nsarray : NSArray;
      lo_pointer : Pointer;
    begin
      if lo_controller.canSendMail then // Access Violation here
      begin
        lo_pointer := Pointer(nil);
        lo_nsarray.arrayByAddingObject(lo_pointer);
        lo_controller.setSubject(StrToNSString('SUJET GENIAL'));
        lo_controller.setMessageBody(StrToNSString('Un Message'), false);
        lo_controller.setToRecipients(lo_nsarray);
        lo_controller.setMailComposeDelegate(FParent);
    
        FParent.mailComposeController(lo_controller, 0, nil);
      end
      else
      begin
        Log('Sorry' + #10#13 + 'You cant send Message '#10#13 +
        '1) Your Device not support Message Compose' + #10#13 +
        '2) Text Messaging not available');
      end;
    end;
    {$ENDIF}
    

    I think my MFMailComposeViewController variable (lo_controller) isn't initialized but i don't know how to do this..
    Thanks advance.

     
  • Chris

    Chris - 2016-02-10

    I think you can use the DPF.iOS.MFMessageCompose class. It uses the MFMailComposeViewController.
    Maybe you can look at the DPF.iOS.MFMessageCompose source and modify it to suit your needs.

    regards
    chris

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.