title: Delphi tray icon (NSStatusItem) for OSX
body: <p>I am trying to add NSStatusItem in a Delphi application for OSX.  Searched for sample code to help me with that but got stuck when defining an interface:</p>
  
  <p>Here is the code:</p>
  
  <pre><code>// Source: https://forums.embarcadero.com/thread.jspa?threadID=108449
  
  unit Unit2;
  
  interface
  
  uses Macapi.ObjectiveC, Macapi.CocoaTypes, Macapi.Foundation, Macapi.AppKit,
  Macapi.Helpers, Macapi.ObjcRuntime, System.TypInfo, FMX.Platform, FMX.Platform.Mac;
  
  type
  TFMXTrayItem = class(TOCLocal)
  private
  NSStatItem : NSStatusItem;
  public
  constructor Create;
  destructor Destroy; override;
  function GetObjectiveCClass: PTypeInfo; override;
  procedure call_mymethod; cdecl;
  end;
  
  implementation
  
  constructor TFMXTrayItem.Create;
  var
  NSContMenu : NSMenu;
  NSContItem : NSMenuItem;
  NSStatBar : NSStatusBar;
  NSImg : NSImage;
  AppBundle : NSBundle;
  NSpImg: Pointer;
  Path: String;
  begin
  inherited Create;
  
  NSStatBar := TNSStatusBar.Create;
  NSStatBar := TNSStatusBar.Wrap(TNSStatusBar.OCClass.systemStatusBar);
  NSStatItem:= NSStatBar.statusItemWithLength(NSVariableStatusItemLength);
  NSStatItem.setTarget(GetObjectID);
  
  // Create context menu
  NSContMenu := TNSMenu.Create;
  NSContMenu := TNSMenu.Wrap(NSContMenu.initWithTitle(StrToNSStr('The caption')));
  
  NSContItem:=TNSMenuItem.Create;
  NSContItem:=TNSMenuItem.Wrap(NSContItem.initWithTitle(StrToNSStr('1. menuitem'),sel_getUid(PAnsiChar('call_mymethod')),StrToNSStr('')));
  NSContItem.setTarget(GetObjectID);
  NSContMenu.addItem(NSContItem);
  NSContItem.release;
  
  
  // Add menu
  NSStatItem.retain;
  NSStatItem.setHighlightMode(true);
  NSStatItem.setMenu(NSContMenu);
  NSContMenu.release;
  
  // Get path to dir
  AppBundle := TNSBundle.Wrap(TNSBundle.OCClass.mainBundle);
  Path:=AppBundle.bundlePath.UTF8String+'/Contents/yourimage16x16.png';
  NSpImg := TNSImage.Alloc.initWithContentsOfFile(StrToNSStr(Path));
  // Create Icon
  NSImg := TNSImage.Create;
  NSImg := TNSImage.Wrap(NSpImg);
  NSStatItem.setImage(NSImg);
  NSImg.release;
  end;
  
  destructor TFMXTrayItem.Destroy;
  begin
  NSStatItem.release;
  inherited;
  end;
  
  function TFMXTrayItem.GetObjectiveCClass: PTypeInfo;
  begin
  Result :=TypeInfo(IFMXTrayItem);
  end;
  
  procedure TFMXTrayItem.call_properties;
  begin
  // your event code of the menu item
  end;
  
  end.
  </code></pre>
  
  <p>Does anyone have any idea on how to declare the IFMXTrayItem interface?</p>