How to display NSTimeInterval binding as NSDate in InterfaceBuilder?
-
03-10-2019 - |
문제
I handle a lot of time stamps that I store as NSTimeInterval.
NSDateComponents* comps = [[NSDateComponents alloc] init];
[comps setYear: ....
NSDate* date = [gregorian dateFromComponents:comps];
NSTimeInterval timeStamp = [date timeIntervalSinceReferenceDate];
Interface Builder has a table view binding to the variable of the time stamp. How can I format the (double value of) NSTimeInterval into a human readable date format? The Interface Builder Table Column Bindings palette has a input field Value Transformer - can I do something here?
해결책
The trick is to drag and drop NSDateFormatter from the Library panel to the table view cell.
제휴하지 않습니다 StackOverflow