I've only ever made ranges in the past using this syntax: 

  range = NSMakeRange(0,1) 

Which allows you to set the start point and length.


On 21/01/2013, at 22:08, "kwic...@wichry.net" <kwic...@wichry.net> wrote:

> I am trying to implement the following method of NSAttributedString in 
> Macruby:
> 
> - (id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index 
> effectiveRange:(NSRangePointer)aRange
> 
> As by definition, it `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, so I need a pointer to NSRange, which I set up as follows:
> 
>    range=Pointer.new("{_NSRange=QQ}")[0]
> 
> It seems to be fine as `range.class` => `NSRange`.
> 
> However, when I execute the method: 
> 
>    
> font=txtStor.attribute(NSFontAttributeName,atIndex:index,effectiveRange:range)
> 
> my `range` is always `#<NSRange location=0 length=0>`. Also, `p range` gives 
> me `#<NSRange location=0 length=0>`.
> 
> Any ideas how to implement this correctly?
> 
> Thanks
> K
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

--
Stephen Horne

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo/macruby-devel

Reply via email to