开发者

The date is always ignored

开发者 https://www.devze.com 2023-01-01 22:16 出处:网络
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!

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

精彩评论

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