git.fiddlerwoaroof.com
Browse code

Update README.org code sample

Ed L authored on 10/01/2018 08:38:55
Showing 1 changed files
... ...
@@ -42,19 +42,22 @@ From demo-app.lisp:
42 42
       [#@NSApplication @(sharedApplication)]
43 43
       [objc-runtime::ns-app @(setActivationPolicy:) :int 0]
44 44
 
45
-      (let ((app-delegate (objc-runtime::objc-allocate-class-pair
46
-                           #@NSObject "AppDelegate" 0)))
47
-        (objc-runtime::add-pointer-ivar app-delegate "window")
48
-        (objc-runtime::add-pointer-ivar app-delegate "delegate"))
49
-
50
-      (let* ((bundle [#@NSBundle @(mainBundle)])
51
-             (nib [[#@NSNib @(alloc)] @(initWithNibNamed:bundle:)
52
-                                      :pointer @"MainMenu"
53
-                                      :pointer bundle]))
54
-        (cffi:with-foreign-object (p :pointer)
55
-          [nib @(instantiateWithOwner:topLevelObjects:)
56
-               :pointer objc-runtime::ns-app
57
-               :pointer p]))
45
+      (objc-runtime::objc-register-class-pair
46
+       (demo-app::make-app-delegate-class '("actionButton"
47
+                                  "alertButton"
48
+                                  "profitButton")))
49
+
50
+      (demo-app::load-nib "MainMenu")
51
+      
52
+      (let ((app-delegate [objc-runtime::ns-app @(delegate)]))
53
+        (demo-app::make-button-delegate (value-for-key app-delegate "actionButton")
54
+                              (cffi:callback do-things-action))
55
+        (demo-app::make-button-delegate (value-for-key app-delegate "alertButton")
56
+                              (cffi:callback alert-action))
57
+        (demo-app::make-button-delegate (value-for-key app-delegate "profitButton")
58
+                              (cffi:callback profit-action)))
59
+      
58 60
       [objc-runtime::ns-app @(activateIgnoringOtherApps:) :boolean t]
59 61
       [objc-runtime::ns-app @(run)]))
62
+
60 63
 #+END_SRC