Existe-t-il un moyen/une méthode pour séparer le mois & année formulaire NSDate?Comment obtenir le mois et l'année de NSDate?
J'ai juste besoin d'afficher le mois en cours & année? Un exemple?
Existe-t-il un moyen/une méthode pour séparer le mois & année formulaire NSDate?Comment obtenir le mois et l'année de NSDate?
J'ai juste besoin d'afficher le mois en cours & année? Un exemple?
Cela pourrait se faire en utilisant NSDateComponents
NSDate *date = [NSDate date];
NSDateComponents *dateComponents = [calendar components:unitFlags fromDate:date];
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
[calendar release];
acclamations endo
Quelle est la variable 'calendar'? –
NSCalendar * calendar = [[allocat NSCalendar] initWithCalendarIdentifier: NSGregorianCalendar]; –
Merci Espo. J'ai obtenu la solution: – Nic
NSDateFormatter * dateformatter = [[NSDateFormatter alloc] init]; – Nic
[dateformatter setDateFormat: @ "MM/jj/aaaa hh: mm a"]; – Nic