Guest User

Untitled

a guest
Nov 21st, 2017
145
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace MacApp1;
  2.  
  3. interface
  4.  
  5. uses
  6.   AppKit,
  7.   Foundation;
  8.  
  9. type
  10.   [IBObject]
  11.   MainWindowController = public class(NSWindowController)
  12.   private
  13.   protected
  14.   public
  15.     [IBOutlet] property Text1 : weak NSTextField;
  16.     [IBOutlet] property JobGrid : weak NSTableView;
  17.     [IBOutlet] property Button1 : weak NSButton;
  18.     [IBAction] method Button1Click(sender : id);
  19.     method init: instancetype; override;
  20.     method windowDidLoad; override;
  21.     method showWindow(sender: nullable id); override;
  22.     property MyTestData : NSArray<testClass>;
  23.   end;
  24.  
  25.   testClass = public partial class
  26.   public
  27.     constructor(AName : String; AZip : Int32; AAge: Int32);
  28.     property Name : String;
  29.     property Zip  : Int32;
  30.     property Age  : Int32;
  31.   end;
  32.  
  33. implementation
  34.  
  35. constructor testClass(AName: String; AZip: Int32; AAge: Int32);
  36.  
  37. begin
  38.   self.Name := AName;
  39.   self.Zip := AZip;
  40.   self.Age := AAge;
  41. end;
  42.  
  43. method MainWindowController.init: instancetype;
  44. begin
  45.   self := inherited initWithWindowNibName('MainWindowController');
  46.   MyTestData := new NSArray<testClass>;
  47.   if assigned(self) then begin
  48.  
  49.     // Custom initialization
  50.  
  51.   end;
  52.   result := self;
  53. end;
  54.  
  55. method MainWindowController.windowDidLoad;
  56. begin
  57.   MyTestData.arrayByAddingObject(new testClass('Alan',53188,52));
  58.   MyTestData.arrayByAddingObject(new testClass('Sam',53188,19));
  59.   MyTestData.arrayByAddingObject(new testClass('Gordon',22222,47));
  60.  
  61.  
  62.   inherited windowDidLoad();
  63.  
  64.   // Implement this method to handle any initialization after your window controller's
  65.   // window has been loaded from its nib file.
  66. end;
  67.  
  68. method MainWindowController.showWindow(sender: id);
  69. begin
  70.  
  71.  // Text1.stringValue := NSString.stringWithFormat("%lld",vcount);
  72. end;
  73.  
  74. method MainWindowController.Button1Click(sender: id);
  75.  
  76. begin
  77.   var vcount := MyTestData.count;
  78.   for each _arr in MyTestData do
  79.     NSLog('Array Entry',_arr.Name);
  80. end;
  81.  
  82. end.
RAW Paste Data