source: release/1.2/source/examples/cocoa/currency-converter/currency-converter.lisp

Last change on this file was 10236, checked in by Gary Byers, 16 years ago

At the lisp level, the #/convert: method on conveter-controller returns
NIL (it returns the value returned by the call to the #/selectText: method
at the end of its body); at the ObjC level, it was implicitly declared
to return :ID, which meant that a type error ("NIL is not of the expected
type MACPTR") was signaled every time the method returned.

Change the method to return :VOID. While we're at it, declare the
SENDER arg to be ignored.

File size: 1.8 KB
RevLine 
[7435]1(in-package "CCL")
2
3;;; define the classes referenced in the nibfile
4
5(defclass converter (ns:ns-object)
6 ()
7 (:metaclass ns:+ns-object))
8
9(objc:defmethod (#/convertCurrency:atRate: :float)
10 ((self converter) (currency :float) (rate :float))
11 (* currency rate))
12
13(defclass converter-controller (ns:ns-object)
14 ((amount-field :foreign-type :id :accessor amount-field)
15 (converter :foreign-type :id :accessor converter)
16 (dollar-field :foreign-type :id :accessor dollar-field)
17 (rate-field :foreign-type :id :accessor rate-field))
18 (:metaclass ns:+ns-object))
19
[10236]20(objc:defmethod (#/convert: :void) ((self converter-controller) sender)
21 (declare (ignore sender))
[7435]22 (let* ((conv (converter self))
23 (dollar-field (dollar-field self))
24 (rate-field (rate-field self))
25 (amount-field (amount-field self))
26 (dollars (#/floatValue dollar-field))
27 (rate (#/floatValue rate-field))
28 (amount (#/convertCurrency:atRate: conv dollars rate)))
29 (#/setFloatValue: amount-field amount)
30 (#/selectText: rate-field self)))
31
32
33
34
35#|
36"/Users/mikel/Valise/clozure/openmcl/example-code/currency-converter/CurrencyConverter.nib"
37
38building the app:
39
40(progn
41 (setf (current-directory) "/Users/mikel/Valise/clozure/openmcl/example-code/currency-converter/")
42 (load "currency-converter")
43 (require "build-application")
44 (ccl::build-application :name "CurrencyConverter"
45 :main-nib-name "CurrencyConverter"
[7786]46 :directory "/Users/mikel/Desktop/"
[7784]47 :nibfiles '(#P"/usr/local/openmcl/trunk/ccl/examples/cocoa/currency-converter/CurrencyConverter.xib")))
[7435]48
49TODO NOTES:
50
51The name of the app in the main menu title is determined by the CFBundleName field in the
52InfoPlist.strings file in the English.lproj resources folder.
53
54|#
Note: See TracBrowser for help on using the repository browser.