私はObjective-C初心者です。高低を検索しましたが、これに対する答えはまだ見つかりません:
私の RubyMotion プロジェクトには、次のような drawLinearGradient というメソッドを含む StatusGuage という UIView サブクラスがあります。
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
CGGradientCreateWithColors の呼び出し方を知りたいです。明らかに (CFArrayRef) ポインターが必要ですが、それを渡す方法がわかりません。試した反復の 1 つがコメントアウトされています。
エラーメッセージは次のとおりです。
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:'
助けてくれてありがとう。