Re: Drawing A Mutable String
Re: Drawing A Mutable String
- Subject: Re: Drawing A Mutable String
- From: Michael Craig <email@hidden>
- Date: Mon, 11 Jan 2010 12:25:08 -0500
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