Macruby で NSAttributedString の次のメソッドを実装しようとしています:
- (id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index effectiveRange:(NSRangePointer)aRange
定義上、それはReturns the value for an attribute with a given name of the character at a given index, and by reference the range over which the attribute applies.
OK、NSRange へのポインタが必要です。次のように設定します。
range=Pointer.new("{_NSRange=QQ}")[0]
range.class=>としても良さそうNSRangeです。
ただし、メソッドを実行すると:
font=txtStor.attribute(NSFontAttributeName,atIndex:index,effectiveRange:range)
私rangeはいつもお世話になってい#<NSRange location=0 length=0>ます。また、私にp range与えます#<NSRange location=0 length=0>。
これを正しく実装する方法はありますか?