Swift Code:
NativeObject Code:
However, when I run this, I get the following error:
B4X:
var messageVC = MFMessageComposeviewController()
messageVC.body = b
messageVC.recipients = r
messageVC.messageComposeDelegate = self;
self.presentViewController(messageVC, animation: false, completion: nill)
NativeObject Code:
B4X:
Sub Class_Globals
Private MC As NativeObject
Private ThePage As Page
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize (P As Page)
ThePage = P
End Sub
Public Sub CreateMessage (TNumber As String, TMessage As String)
MC.Initialize("MFMessageComposeViewController")
MC.SetField("body", TMessage)
MC.SetField("recipients", TNumber)
End Sub
Public Sub ShowDialog
MC.SetField("messageComposeDelegate", ThePage)
Dim PNO As NativeObject = ThePage
PNO.RunMethod("presentViewController", Array(MC, False, Null))
End Sub
However, when I run this, I get the following error:
Application_Start
Error occurred on line: 14 (iMessageComposer)
[<MFMessageComposeViewController 0x1b35ada60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key body.
Stack Trace: (
CoreFoundation <redacted> + 148
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
Foundation <redacted> + 272
OLX Testing -[B4INativeObject SetField::] + 140
OLX Testing -[b4i_imessagecomposer _createmessage:::] + 868
OLX Testing -[b4i_main _application_start:] + 1808
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
OLX Testing +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
OLX Testing -[B4IShell runMethod:] + 448
OLX Testing -[B4IShell raiseEventImpl:method:args::] + 1260
OLX Testing -[B4IShellBI raiseEvent:event
arams:] + 1408
OLX Testing __33-[B4I raiseUIEvent:event
arams:]_block_invoke + 60
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib <redacted> + 968
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 2012
CoreFoundation CFRunLoopRunSpecific + 436
GraphicsServices GSEventRunModal + 100
UIKit UIApplicationMain + 208
OLX Testing main + 124
libdyld.dylib <redacted> + 4
)
Error occurred on line: 14 (iMessageComposer)
[<MFMessageComposeViewController 0x1b35ada60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key body.
Stack Trace: (
CoreFoundation <redacted> + 148
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
Foundation <redacted> + 272
OLX Testing -[B4INativeObject SetField::] + 140
OLX Testing -[b4i_imessagecomposer _createmessage:::] + 868
OLX Testing -[b4i_main _application_start:] + 1808
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
OLX Testing +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
OLX Testing -[B4IShell runMethod:] + 448
OLX Testing -[B4IShell raiseEventImpl:method:args::] + 1260
OLX Testing -[B4IShellBI raiseEvent:event
OLX Testing __33-[B4I raiseUIEvent:event
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib <redacted> + 968
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 2012
CoreFoundation CFRunLoopRunSpecific + 436
GraphicsServices GSEventRunModal + 100
UIKit UIApplicationMain + 208
OLX Testing main + 124
libdyld.dylib <redacted> + 4
)