質問

We need to take the actual date from the IPad and save it in a variable. We have searched NSDateComponents and NSDate, but we havent found anything. For example if today is 25 of october, we would like to have a int with the value of 25 and another with 10 (october).

We will appreciate any help. Thank you!!

役に立ちましたか?

解決

What did you try?

Did you at least read the Date and Time Programming Guide about the subject which explains everything?

The Listing 5 in the documentation gives you pretty much the answer directly

NSDateComponents *comps = [[NSCalendar currentCalendar] components:(NSDayCalendarUnit | NSMonthCalendarUnit) fromDate:[NSDate date]];
NSInteger day = [comps day];
NSInteger month = [comps month];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top