Objective-C stringWithFormat misses an argument?
Posted
by rocity
on Stack Overflow
See other posts from Stack Overflow
or by rocity
Published on 2010-06-09T01:19:37Z
Indexed on
2010/06/09
1:32 UTC
Read the original article
Hit count: 228
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.
© Stack Overflow or respective owner