开发者

error getting time from phone in xcode 4?

I trying to fetch the time from the phone's clock but am not able to fetch using this code

NSDate *today = [NSDate date];
    NSCalendar *gregorian = [[NSCalendar alloc]
                             initWithCalendarIdentifier:NSGregorianCalendar];

NSInteger hour = [components hour];
    NSInteger minute = [components minute];
    NS开发者_运维问答Integer second = [components second];


Use This

NSDate *today = [NSDate date];
    NSCalendar *gregorian = [[NSCalendar alloc]
                             initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components =
    [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:today];

    NSInteger hour = [components hour];
    NSInteger minute = [components minute];
    NSInteger second = [components second];

You missed a line in the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜