I get those two errors: - Can not use an object as parameter to a method - Incompatible types in return
That's my code:
- (NSString) dateStringFromUnixTimeStamp:(NSInteger)timeStamp {
//Create Date-String from UNIX-Time-Stamp:
NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeStamp];
NSDateComponents *monthComponents = [[NSCalendar currentCalendar] components:NSMonthCalendarUnit fromDate:date];
int month = [monthComponents month];
NSDateComponents *dayComponents = [[NSCalendar currentCalendar] components:NSDayCalendarUnit fromDate:date];
int day = [dayComponents day] - 1;
NSDateComponents *yearComponents = [[NSCalendar currentCalendar] components:NSYearCalendarUnit fromDate:date];
int year = [yearComponents year];
NSString *monthString;
switch (month) {
case 1:
monthString = @"Januar";
break;
case 2:
monthString = @"Februar";
break;
case 3:
monthString = @"März";
break;
case 4:
monthString = @"April";
break;
case 5:
monthString = @"Mai";
break;
case 6:
monthString = @"Juni";
break;
case 7:
monthString = @"Juli";
break;
case 8:
monthString = @"August";
break;
case 9:
monthString = @"September";
break;
case 10:
monthString = @"Oktober";
break;
case 11:
monthString = @"November";
break;
case 12:
monthString = @"Dezember";
break;
default:
break;
}
NSString *dateString = [[NSString stringWithFormat:@"%d", day] stringByAppendingString:@". "];
dateString = [dateString stringByAppendingString:monthString];
dateString = [dateString stringByAppendingString:@" "];
dateString = [dateString stringByAppendingString:[NSString stringWithFormat:@"%d", year]];
return dateString;
}
Thanks for help!