Re: Drawing A Mutable String
Re: Drawing A Mutable String
- Subject: Re: Drawing A Mutable String
- From: Andy Lee <email@hidden>
- Date: Mon, 11 Jan 2010 16:15:16 -0500
Bizarre. I love bugs like this that it's easy to prove can't possibly be happening. :)
The only desperate, farfetched suggestion I have is that somehow you've accidentally created two instances of your GameView, only one of which is visible, and for some reason when invalidStack is true, the correct drawing *is* happening but in the wrong view. I would think this would be obvious if it were the case, but still, what if you add the following line?
NSLog(@"%@ -- %p", [self className], self);
Do you always see the same pointer value printed? As I said, farfetched, but I see that like me, you like to test the most basic assumptions.
Also, I assume you aren't calling drawRect: directly, right? Or setNeedsDisplay:NO, or any other dirty rect manipulation?
I'd be willing to look at the code, with complete respect for confidentiality, if you're trusting enough to send it to me and at liberty to do so.
--Andy
On Monday, January 11, 2010, at 12:25PM, "Michael Craig" <email@hidden> wrote:
>Andy: There's nothing drawing over it. I can move that chunk of code to the
>end of drawRect: with the same result.
>
>Quincy: rightAligned is a paragraph style object that's defined elsewhere in
>drawRect and used in a few different places.
>
>Fritz: All four things you mention are apparently true when I run it through
>the debugger, so the if statement must be working. What's more, I can see
>that it's working by inserting a printf inside (or after) the if and seeing
>the fully appended string there.
>
>How is it possible that I can append the value of infoStr, see that new
>value at the console with printf, then draw it and get the old value?
>
>Also, I can appended another string to infoStr after the invalidStack if
>statement and it gets drawn (always, since it's not in an if), but the
>string appended in the invalidStack if statement still doesn't get drawn.
>They both show up in the console when I printf infoStr, but the invalidStack
>piece in the middle of the string is left out when infoStr is drawn.
>
>Gah!
>
>Michael S Craig
>(908) 328 8030
>
>
>On Thu, Jan 7, 2010 at 4:18 PM, Fritz Anderson <email@hidden>wrote:
>
>> On 7 Jan 2010, at 2:29 PM, Michael Craig wrote:
>>
>> > if ([theDeck.cardPile count] == 0) {
>> > [infoStr appendString: @"\n\nThe deck is empty."]; //
>> > *2*
>> > }
>> > if (gameCon.invalidStack) {
>> > [infoStr appendString: @"\n\nThat's an invalid stack."]; //
>> > *1*
>> > }
>> > [infoStr drawInRect: infoRect
>> > withAttributes: infoAtts];
>> ...
>> > If I move the line marked *1* to come after the line marked *2*, then
>> both
>> > messages are drawn when the deck is empty, as one would expect.
>> >
>> > If I move the line marked *1* one line down (so it's outside of the
>> > invalidStack if statement and the if is empty), then invalidStack message
>> is
>> > drawn at all times, as one would expect.
>> >
>> > So what is keeping it from drawing the appended text when it happens
>> inside
>> > the invalidStack if statement? Like I said above, the if statement itself
>> > works fine.
>>
>> I don't understand why you say "the if statement works fine." You say it
>> doesn't execute its body when you think its condition is true. That means it
>> doesn't work fine, doesn't it?
>>
>> When you execute this code line-by-line in the debugger, do you see with
>> your own eyes:
>>
>> • gameCon (assuming it is an object pointer) is not nil?
>> • gameCon.invalidStack is non-zero?
>> • Control ever reaches line 1?
>> • infoStr changes content?
>>
>> — F
>>
>>
>_______________________________________________
>
>Cocoa-dev mailing list (email@hidden)
>
>Please do not post admin requests or moderator comments to the list.
>Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>Help/Unsubscribe/Update your Subscription:
>
>This email sent to email@hidden
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden