I've implemented the selector alertDidEnd:returnCode:contextInfo:
. The last parameter, contextInfo, is a void pointer. Before calling the method I put the pointer together as follows.
# in windowShouldClose
p = Pointer.new(:boolean)
p.assign(true)
Then I call the method, and inside its body have the following:
# in alertDidEnd
puts p[0] # => a number like 245
puts p.cast!('B')[0] # => false (rather than true)
What am I doing wrong? Is this because the calling method (windowShouldClose) finishes in its own thread before this selector has a chance (just guessing)?
Or should I be creating the pointer as an object pointer?
# make a pointer to an object and assign to it the instance of TrueClass
p = Pointer.new(:id)
p.assign(true)
I've read what the O'reilly Macruby Book has to say about this.
Thanks!