[Openmcl-devel] Defining new objective C types
minerva at agentsheets.com
Wed Mar 9 19:44:51 UTC 2011
I am curious if there is a way to define a new objc type that will be recognized by objc methods as a parameter, I thought I could just find where :<NSI>nteger was defined but I had no luck when I looked for that definition. Most of the time you can just list your parameter without a type but it seems that in the case of an NSTimer you may need to define the type explicitly. Here is my little example that seems to need this explicit type definition for the timer parameter:
(defclass COCOTRON-VIEW (ns:ns-opengl-view)
(defun COCOTRON-TEST ()
(ns:with-ns-rect (frame 0 0 200 200)
(let* ((window (make-instance ns:ns-window :height 300))
(opengl-view (#/retain (#/initWithFrame:pixelFormat: (#/alloc cocotron-view) frame (#/defaultPixelFormat ns:ns-opengl-view))))
(timer (#/retain (#/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: ns:ns-timer .01d0 opengl-view (objc::@selector #/timer:) nil #$YES)))) ;;***********This is the line of importance***************
(#/orderFront: window nil))))
(objc:defmethod (#/timer: :void) ((self cocotron-view) timer)
It seems to me that this code should work but timer is never printed, I believe the problem is because I am not explicitly defining the type of the parameter. The documentation of the method #/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: states that the selector must have the following signature:
So I assume my problem is that I am defining the type of the timer loosely. Anyone know how I could explicitly define the parameter in this example? Something like this:
(objc:defmethod (#/timer: :void) ((self cocotron-view) (timer ns:ns-timer))
gives this error:
> Error: Unknown foreign type: NS:NS-TIMER
> While executing: CCL::%PARSE-FOREIGN-TYPE, in process Listener(11).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.
Thanks a lot,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Openmcl-devel