Hi, On 3 Jun 2013, at 18:15, Slex Sangiuliano <alex2...@hotmail.com> wrote:
> + NSCalendar *gregorian = [[NSCalendar alloc] > initWithCalendarIdentifier:NSGregorianCalendar]; > + NSDateFormatter *form = [[NSDateFormatter alloc] init]; Rather than creating and destroying these every update, it might be better to create them in -init, store them in an ivar, and reuse them. > + NSDate * date = [NSDate date]; > + NSDateComponents *dateComponents = [gregorian > components:NSWeekdayCalendarUnit fromDate:date]; > + > + NSInteger weekDayNum = [dateComponents weekday]; Looks fine. > + [form setDateFormat:@"dd/MM/yyyy HH:mm"]; Likewise, this setup should only need to be done once if you reuse form (I'd rename it to dateFormatter or something similarly expressive). > + NSArray *shortDayName = [form shortWeekdaySymbols]; You could cache this in an ivar too, as it will only change if the current locale changes. In > + NSString *strDate = [NSDateFormatter localizedStringFromDate:date > dateStyle:NSDateFormatterNoStyle timeStyle:NSDateFormatterShortStyle]; > + NSString *dayNum = [form stringFromDate:date]; > + [view setTitle: [NSString stringWithFormat:@"%@ %@ %@", [shortDayName > objectAtIndex:weekDayNum], [dayNum substringToIndex:2], strDate]]; > + > + [gregorian release]; > + [form release]; David -- Sent from my Cray X1 _______________________________________________ Etoile-dev mailing list Etoile-dev@gna.org https://mail.gna.org/listinfo/etoile-dev