Question

-(void)updateString

    {
        NSString * timeStampString = @"1316641549";
        NSTimeInterval _interval=[timeStampString doubleValue];
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
        NSLog(@"%@", date);

        [webView reload:0];
        [self.textField setStringValue:@"hi",date];
    }

Can someone quickly tell me what im doing wrong? I am trying to set my text field equal to my date but the [self.textField setStringValue:@"hi",date]; is returning "Too many arguments" What does the formattting need to be? textField is a NSTextField. Thanks!

Was it helpful?

Solution

NSString *dateString = [NSDateFormatter localizedStringFromDate:date 
                                                      dateStyle:NSDateFormatterShortStyle 
                                                      timeStyle:NSDateFormatterFullStyle];

[self.textField setStringValue:[NSString stringWithFormat:@"hi %@", dateString]];

OTHER TIPS

NSString *Datestr = [NSDateFormatter localizedStringFromDate:[NSDate date] dateStyle:NSDateFormatterLongStyle timeStyle:NSDateFormatterMediumStyle];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top