我試圖實現NSAttributedString中的MacRuby以下方法返回值:MacRuby的指針和對象 - 功能通過引用
- (ID)屬性:(的NSString *)的attributeName atIndex:(NSUInteger)指數effectiveRange:(NSRangePointer)人氣指數
作爲由定義,它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.
行,所以我需要一個指針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>
。
任何想法如何正確實施?