Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:52:37+00:00 2026-06-17T18:52:37+00:00

I am trying to implement the following method of NSAttributedString in Macruby: (id)attribute:(NSString *)attributeName

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:52:38+00:00Added an answer on June 17, 2026 at 6:52 pm

    I was given the solution by Watson at the MacRuby-devel mailing list. I should have written my code like that:

     range=Pointer.new(NSRange.type)
     #though range=Pointer.new("{_NSRange=QQ}") would also work
    

    then, as I had before

    font=txtStor.attribute(NSFontAttributeName,atIndex:index,effectiveRange:range)
    

    and if needed I could dereference the range by range[0].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the following method: void Ball::DrawOn(Graphics g); The method should draw
I have the following complex method. I'm trying to find and implement possible improvements.
I am trying to implement the following algorithm using the divide and conquer method
I am trying to implement the following method in my application NSSet *nearbySet =
Using eclipse 4.2 with Java 7 and trying to implement the following method of
I am trying to implement the following in a method in one of my
I am trying to implement the jQuery Deferred.pipe() method for the following scenario: Add
I am trying to implement the following method of QLPreviewControllerDelegate and the method requires
Following this question , I am trying to implement an async method using the
I am trying to implement the following method to get the bus corresponding to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.