[Openmcl-devel] Errors Creating NSTimer

Gary Byers gb at clozure.com
Wed Oct 24 05:20:17 UTC 2007

The first argument to any ObjC method should be the "receiver" (the
object - instance (usually) or class (sometimes) - that might implement
a method on the message.  If this were CLOS, we might call the receiver
the first and only specialized parameter.)

In the case of
the receiver is the class "NSTimer" (which happens to be the value
of the variable NS:NS-TIMER.)  The bridge is complaining because
the first argument in your calls below either isn't a pointer at
all or isn't a pointer to an ObjC class or instance; getting a lisp-level
error like that is probably better than trying to send a message to
0.01d0 ...

On Tue, 23 Oct 2007, Brent Fulgham wrote:

> I'm trying to get the right Cocoa bridge syntax for calling:
> scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
> Returns a new NSTimer object and adds it to the current NSRunLoop object in 
> the default mode.
> + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds 
> target:(id)target selector:(SEL)aSelectoruserInfo:(id)userInfo 
> repeats:(BOOL)repeats
> NSTimeInterval is just a typedef to double, so I thought that I could just 
> pass the double value to the function, since this is how many of the example 
> Objective C programs are written, but this does not work for a variety of 
> reasons:
> 1.  If I attempt to simply use a bare double, it's not happy:
>  (let* ((TimerInterval (ccl::%double-float 0.01)))
>            (Timer 
> (#/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: 
> TimeInterval (cocoa-view self) (objc:@selector #/animate) (ccl::%null-ptr) 
> #$YES)))
>> Error: value 0.009999999776482582D0 is not of the expected type MACPTR.
>> While executing: CCL::SEND-UNAMBIGUOUS-MESSAGE, in process listener(1).
> 2.  If I attempt to use an RLET to allocate the C Type, it's still not happy:
> (rlet ((TimeInterval :<NST>ime<I>nterval (ccl::%double-float 0.01)))
>   (let* (
>          (Timer 
> (#/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: 
> TimeInterval (cocoa-view self) (objc:@selector #/animate) (ccl::%null-ptr) 
> #$YES))))
>     ;; add myself to list
>     (pushnew Self (animated-views Self))))
>> Error: value #<A Foreign Pointer [stack-allocated] (:* DOUBLE-FLOAT) 
>> #xB029BE70> is not of the expected type OBJC:OBJC-OBJECT.
>> While executing: CCL::SEND-UNAMBIGUOUS-MESSAGE, in process listener(1).
> I vaguely remember a mechanism to convert native C types to Cocoa analogs, 
> but I cannot find documentation of this, and may be mixing Objective C up 
> with something up.
> What's the correct way to deal with this particular API call?
> Thanks,
> -Brent

More information about the Openmcl-devel mailing list