How to split a string in objective-C? I am working on an short application that contains a date picker. I do display date get it from date picker and display it through a la
You can use following code to split the date into separate components:
NSDate *inputDate = [NSDate date]; //assign the value selected from date picker
NSCalendar* calendar = [NSCalendar currentCalendar];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents* componentObj = [calendar components:unitFlags fromDate:inputDate];
NSInteger day = componentObj.day;
NSInteger month = componentObj.month;
NSInteger year = componentObj.year;