[MacRuby] #1049: Can't get the event path from FSEventStreamCallback
MacRuby
ruby-noreply at macosforge.org
Wed Dec 15 17:04:10 PST 2010
#1049: Can't get the event path from FSEventStreamCallback
---------------------------+------------------------------------------------
Reporter: haxie1@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
---------------------------+------------------------------------------------
MacRuby 0.9 r5024
BridgeSupport Preview 2
{{{
framework 'Foundation'
framework 'CoreServices'
callback = Proc.new do |stream, callback_info, numb_events, paths, flags,
ids|
puts "callback"
puts paths #Pointer
puts paths.type #C
paths.cast!("@")
puts paths[0] #NSCFArray
paths[0].count
#crash
end
context = nil
watchPath = ["/Users/Shared"]
stream = FSEventStreamCreate(KCFAllocatorDefault, callback, context,
watchPath, KFSEventStreamEventIdSinceNow, 0.3,
KFSEventStreamCreateFlagUseCFTypes)
if !stream
puts "Failed"
exit 1
end
queue = Dispatch::Queue.new("fseventqueue")
p = queue.dispatch_object
FSEventStreamSetDispatchQueue(stream, p)
if ! FSEventStreamStart(stream)
puts "Failed to start"
exit 1
end
trap("INT") {
FSEventStreamStop(stream)
FSEventStreamInvalidate(stream)
exit 0
}
Dispatch::Queue.main.run
}}}
When I run this, I get called back when /Users/Shared changes, but my
callbacks 'paths' argument doesn't have any useful data. If I cast the
paths Pointer to an object I get an NSCFArray, but calling anything on it
throws an exception (NoMethodError).
Am I doing it wrong, or is the callbacks 'paths' param pointing to the
great unknown?
--
Ticket URL: <http://www.macruby.org/trac/ticket/1049>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list