tags:

views:

31

answers:

1

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:(CLLocationCoordinate2D)c title:(NSString *)t
{
 [super init];
 coordinate = c;
 NSDate *today = [NSDate date];

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

 //[today release];
 return self;
}
+2  A: 

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.

walkytalky