delphi - XE4 ( Firemonkey + iOS Static Library) , Pascal conversion from Objective C Class? -


how conversion ? (objective c class -> delphi xe4 )

and how use objective-c class in static library delphi xe ?

following first trial. makes error.

objective c source

// objective c : test.h ---------------------------------------- @interface objc_test : nsobject {   bool busy; }  - (int) test :(int) value; @end  // objective c : test.m ---------------------------------------- @implementation objc_test - (int) test :(int) value {     busy   = true;     return( value + 1);  } @end 

here wrong conversion code. how fix ?

delphi source

// delphi xe4 / ios  ------------------------------------------- {$l test.a} // objc static library   type  objc_test = interface (nsobject)  function  test(value : integer) : integer; cdecl; end;  tobjc_test = class(toclocal)   public    function  getobjectivecclass : ptypeinfo; override;    function  test(value : integer): integer; cdecl;  end;  implmentation    function  tobjc_test.getobjectivecclass : ptypeinfo;  begin   result := typeinfo(objc_test);  end;  function  tobjc_test.test(value : integer): integer;  begin   // ????????   //  end; 

thanks

simon,choi

when want import objective c class have following:

type   //here define class it's non static methods   objc_test = interface (nsobject)     [interfaceguid]     function  test(value : integer) : integer; cdecl;        end;  type   //here define static class methods    objc_testclass = interface(nsobjectclass)     [interfaceguid]   end;  type   //the tocgenericimport maps objc classes delphi interfaces when call create of tobjc_testclass   tobjc_testclass = class(tocgenericimport<objc_testclass, objc_test>) end; 

also need dlopen('test.a', rtld_lazy) (dlopen defined in posix.dlfcn)

then can use code following:

procedure test; var    testclass: objc_test; begin    testclass := tobjc_testclass.create;    testclass.test(3);  end; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -