I'm an Objective-C noob, have searched high and low not finding the answer to this yet:
In my RubyMotion project I have a UIView subclass called StatusGuage, which contains a method called drawLinearGradient as follows:
def drawLinearGradient(context, rect, startColor, endColor)
colorspace = CGColorSpaceCreateDeviceRGB()
locations = [0.0, 1.0]
# colors = NSArray.arrayWithObjects(startColor, endColor, nil)
# ptrColors = Pointer.new(:object, colors)
colors = [startColor, endColor, nil]
# CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef) colors, locations);
CGGradientCreateWithColors(colorspace, colors, locations)
end
I'd like to know how to call CGGradientCreateWithColors. It clearly expects a (CFArrayRef) pointer but I cannot figure out how to pass that in. One of the iterations that I've tried is commented out.
Here is the error message:
2012-05-11 16:57:36.331 HughesNetMeter[34906:17903]
*** Terminating app due to uncaught exception 'TypeError',
reason: 'status_guage.rb:43:in `drawLinearGradient:': expected
instance of Pointer, got `[0.0, 1.0]' (Array) (TypeError)
from status_guage.rb:13:in `drawRect:'
Thanks for any help.