Issues with initWithFormat value from server

送分小仙女□ 提交于 2019-12-13 09:04:33

问题


Please how do I make my initWithFormat to display in as 8:00am - 2:30pm?

Help please!! I have already added "dd-MM-yyyy 'at' h:mm:ss a"

//opening
    NSString *startDate= ((Timeslot *)[self.timeslots objectAtIndex:i]).startDateTime;
    NSArray *split =[startDate componentsSeparatedByString: @"T"];
    NSString* clock =[split objectAtIndex: 1];
    NSArray *aux= [clock componentsSeparatedByString:@":"];
    NSString *startTime = [[NSString alloc] initWithFormat:@"%@:%@",[aux objectAtIndex:0],[aux objectAtIndex:1]];

    NSArray *st = [sttHour componentsSeparatedByString: @":"];
    if([[st objectAtIndex:0] integerValue] < [[aux objectAtIndex:0] integerValue])
    {
        if(![self.openings containsObject:startTime])
        {
            [self.openings addObject:startTime];
            [self.closings addObject:startTime];
        }

        [self.frees addObject:startTime];
    }

This is the value I am getting from the server:

Timeslot =  {
            endDateTime = "2014-07-25T16:00:00";
            id = 1344;
            startDateTime = "2014-07-25T14:00:00";
        };

回答1:


Here's a Apple's documentation. You better read this first.

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html



来源:https://stackoverflow.com/questions/24929005/issues-with-initwithformat-value-from-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!