objective c - Can Delphi XE4 import iOS ObjC Class ? ( Static Library *.a ) -


can delphi xe4 import ios objc class ? ( static library *.a )

objc code : test.a

// test.h --------------------------------------------------------------- #import <foundation/foundation.h> @interface mycalc : nsobject {    bool busy;   } - (int) calc : (int) value; @end   //  test.m -------------------------------------------------------------- #import "test.h" @implementation mycalc  -(int) calc:(int)value {     busy = true;     return ( value + 1);   } @end 

delphi xe4 code "unit1.pas" testing

unit1;  interface  uses   system.sysutils, system.types, system.uitypes, system.classes,    system.variants,system.typinfo,   fmx.types, fmx.controls, fmx.forms, fmx.dialogs, fmx.stdctrls,   //   posix.dlfcn,   macapi.objectivec,macapi.objcruntime,   iosapi.cocoatypes,iosapi.foundation,iosapi.uikit,iosapi.coregraphics;  {$link libtest.a} // <-- objc static library (3 architectures included)                   //     compiled binary size same,                   //     or without "$link libtest.a" lines.  type   //   mycalc = interface(nsobject)    ['{12891142-0f45-410d-a9ef-212f1ae23294}'] // unique guid    function  test(value : integer) : integer; cdecl;    end;    mycalcclass = interface(nsobjectclass)    ['{42891142-0f45-410d-a9ef-212f1ae23295}'] // unique guid    end;    //the tocgenericimport maps objc classes delphi interfaces    // when call create of tobjc_testclass   tmycalcclass = class(tocgenericimport<mycalcclass, mycalc>) end;    // -------------------------------------------------------------------------   tform1 = class(tform)     button1: tbutton;     procedure button1click(sender: tobject);   private   public   end;  var   form1: tform1;  implementation  {$r *.fmx}  procedure tform1.button1click(sender: tobject);  var   occalc : mycalc;   rtn    : integer;   handle : integer; begin  handle := dlopen('libtest.a',rtld_lazy); // ## q2 : right ?  occalc := tmycalcclass.create;           // ## q3 : error :                                           //          can't found objc class mycalc    rtn := occalc.test(100);                    button1.text := 'rst:' + inttostr(rtn); end;  end. 

i rewrite code lars' advice xe4 ( firemonkey + ios static library) , pascal conversion objective c class?, compiling ok.

but, after running program in ipad3 device, when press button, shows "objectivec class myclac cound not found"

my questions are

q1. right syntax xe4 & ios static library ?

q2. / wihtout line {$link libtest.a} compiled size same always. what's wrong in code ?

q3. know ios app can't use static library except apple library. so, dlopen not required. right ?

always thanks

simon, choi


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -