开发者

The date is always ignored

I cannot understand why the date is never set in the title - it's always ignored and if I swap around the date and the title, then the title is ignored!

-(id)initWithCoordinate:(开发者_Go百科CLLocationCoordinate2D)c title:(NSString *)t
{
 [super init];
 coordinate = c;
 NSDate *today = [NSDate date];

 [self setTitle:(@"%@%@", [today description], t)];

 //[today release];
 return self;
}


You want:

[self setTitle:[NSString stringWithFormat:@"%@%@", [today description], t]];

Your version isn't building a new string, it's just listing three, of which the last one is used. That's the behaviour of a bunch of expressions in brackets separated by commas like this in C.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜