source: release/1.5/source/contrib/krueger/InterfaceProjects/Utilities/nib.lisp

Last change on this file was 13390, checked in by Paul Krueger, 15 years ago

New contrib from Paul Krueger

File size: 1.6 KB
Line 
1;; nib.lisp
2;; Start with some corrected functions from .../ccl/examples/cocoa/nib-loading/HOWTO.html
3
4(defpackage :interface-utilities
5 (:nicknames :iu)
6 (:export load-nibfile))
7
8(in-package :iu)
9
10;; Note that callers of this function are responsible for retaining top-level objects if
11;; they're going to be around for a while and them releasing them when no longer needed.
12
13(defun load-nibfile (nib-path &key (nib-owner #&NSApp) (retain-top-objs nil))
14 (let* ((app-zone (#/zone nib-owner))
15 (nib-name (ccl::%make-nsstring (namestring nib-path)))
16 (objects-array (#/arrayWithCapacity: ns:ns-mutable-array 16))
17 (toplevel-objects (list))
18 (dict (#/dictionaryWithObjectsAndKeys: ns:ns-mutable-dictionary
19 nib-owner #&NSNibOwner
20 objects-array #&NSNibTopLevelObjects
21 (%null-ptr)))
22 (result (#/loadNibFile:externalNameTable:withZone: ns:ns-bundle
23 nib-name
24 dict
25 app-zone)))
26 (when result
27 (dotimes (i (#/count objects-array))
28 (setf toplevel-objects
29 (cons (#/objectAtIndex: objects-array i)
30 toplevel-objects)))
31 (when retain-top-objs
32 (dolist (obj toplevel-objects)
33 (#/retain obj))))
34 (#/release nib-name)
35 ;; Note that both dict and objects-array are temporary (i.e. autoreleased objects)
36 ;; so don't need to be released by us
37 (values toplevel-objects result)))
38
39(provide :NIB)
Note: See TracBrowser for help on using the repository browser.