views:

56

answers:

2

When I run this code:

- (NSString *)description{
    return [NSString stringWithFormat:@"(FROG idle:%i animating:%i rect:%@ position:%@ tongue:%@)", 
                                    self.idleTime, 
                                    self.animating, 
                                    NSStringFromCGRect(self.rect), 
                                    NSStringFromCGPoint(self.position),
                                    tongue
            ];
}

I get the following output:

(FROG idle:0 animating:0 rect:(null) position:{{1,2}{3,4}} tongue:{5,6})

This is wrong because it seems to be skipping the rect format string and placing everything displaced by one. So idle and animating are what I expect, then rect is skipped, but the result from NSStringFromCGRect(self.rect) is placed into position, then the result for position is pushed to tongue, then tongue is not displayed at all.

I'm at a loss.

+1  A: 

I can't tell without the declarations for idleTime and animating, but one or both of this is probably the wrong type for the %i specifier. Perhaps idleTime is a double (NSTimeInterval)?

Depending on what their actual types are, you could convert them to int:

                                (int)self.idleTime, 
                                (int)self.animating, 
progrmr
this was the answer. i changed the nstimeinterval format string from %i to %a, since it is a double value. all fixed! thanks! i think i might've just been a little tired
rocity
+1  A: 

self.rect must not be a valid CGRect. Are you sure you don't mean self.frame?

DougW