mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-07 18:12:41 +02:00
74 lines
1.1 KiB
ObjectPascal
74 lines
1.1 KiB
ObjectPascal
unit fdt_objccategory;
|
|
|
|
{$mode objfpc}{$H+}
|
|
{$ModeSwitch objectivec1}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils;
|
|
|
|
type
|
|
|
|
{ TMyClass }
|
|
|
|
TMyClass = objcclass(NSObject)
|
|
end;
|
|
|
|
{ TCategoryA }
|
|
|
|
TCategoryA = objccategory(NSObject)
|
|
procedure categoryAmethod; message 'categoryAmethod';
|
|
end;
|
|
|
|
{ TCategoryB }
|
|
|
|
TCategoryB = objccategory(TMyClass)
|
|
procedure categoryBmethod; message 'categoryBmethod';
|
|
end;
|
|
|
|
{ TCategoryC }
|
|
|
|
TCategoryC = objccategory(TMyClass)
|
|
// contrary to helpers there can be multiple ObjCCategory active for a class
|
|
procedure categoryCmethod; message 'categoryCmethod';
|
|
end;
|
|
|
|
procedure DoIt;
|
|
|
|
implementation
|
|
|
|
{ TCategoryA }
|
|
|
|
procedure TCategoryA.categoryAmethod;
|
|
begin
|
|
|
|
end;
|
|
|
|
{ TCategoryB }
|
|
|
|
procedure TCategoryB.categoryBmethod;
|
|
begin
|
|
|
|
end;
|
|
|
|
{ TCategoryC }
|
|
|
|
procedure TCategoryC.categoryCmethod;
|
|
begin
|
|
|
|
end;
|
|
|
|
procedure DoIt;
|
|
var
|
|
a: TMyClass;
|
|
begin
|
|
a:=TMyClass(TMyClass.alloc).init;
|
|
a.categoryAmethod{declaration:fdt_objccategory.TCategoryA.categoryAmethod};
|
|
a.categoryBmethod{declaration:fdt_objccategory.TCategoryB.categoryBmethod};
|
|
a.categoryCmethod{declaration:fdt_objccategory.TCategoryC.categoryCmethod};
|
|
end;
|
|
|
|
end.
|
|
|