[Openmcl-devel] Errors Creating NSTimer

Brent Fulgham bfulg at pacbell.net
Tue Oct 23 22:00:03 PDT 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20071023/716a10d4/attachment.htm>


More information about the Openmcl-devel mailing list