[MacRuby-devel] printing

Laurent Sansonetti lsansonetti at apple.com
Wed Dec 3 14:00:04 PST 2008


Hi John,

On Dec 3, 2008, at 8:45 AM, John Shea wrote:

> Hello all,
>
> has anyone done any printing in MacRuby?

Some examples that ship with MacRuby (such as PathDemo or PagePacker)  
implement a printing facility. I don't really remember how it's  
implemented but maybe this can help you.

> I can get it to print ok - if I select the page range, otherwise the  
> print routine wants to print thousands (or more - i got scared and  
> stopped it) pages.
>
> The rectForPage and the drawRect get called those thousands of times  
> - even though the range should be 1 page.
>
> I suspect that the issue is in the knowsRangePage - it is passed a  
> pointer.
>
> I de reference the pointer with range = range_pointer[0]  (which  
> does give me a range) and then set values with range.location = etc,  
> etc
> (rather than range_pointer->location  =  1 , in Objective C)

range_pointer[0] will return you a completely new NSRange object. If  
you alter the object it's not going to alter the range_pointer object.

Do you re-assign the object back to the pointer?

r = range_pointer[0]
r.location += 1
range_pointer.assign(r)

> My suspicion is that although i set the range length and location  
> that in fact it is not changing the original pointer appropriately,  
> but perhaps inappropriately ;-) with a very large number (a memory  
> address perhaps?).
>
> Anyone else had this issue?

Otherwise, could you share with us a sample project that reproduces  
the problem? Maybe it's a bug in MacRuby.

Laurent


More information about the MacRuby-devel mailing list