nsdate

iOS 10 bug? NSDate hour description with Japan region and 24-Hour Time off

混江龙づ霸主 提交于 2019-12-23 19:10:30
问题 This seems like an iOS 10 bug. It is OK in iOS 8 and 9. The hour description is wrong for [NSDate date].description. It is appending the 24 hour description and 12 hour description. I am not using NSDateFormatter. Just the default settings. On a real iOS 10 device, in Settings: Set Region to Japan in Settings > General > Language & Region > Region Formats > Region Set 24-Hour Time Off in Settings > General > Date & Time > 24-Hour Time Then with: NSLog(@"Date is %@", [NSDate date].description)

exc_bad_access on [NSDate timeIntervalSinceReferenceDate]

六月ゝ 毕业季﹏ 提交于 2019-12-23 19:00:51
问题 I'm getting weird behavior out of [NSDate timeIntervalSinceReferenceDate] . I have the following function: -(void) insertRow{ NSTimeInterval timeNow = [NSDate timeIntervalSinceReferenceDate]; if (timeNow - secondsSinceTableViewScroll <0.5){ [self insertRow]; return; } NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:[self.itemsToFollow count] - 1]; [self.tableView insertSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; } which is a callback from an ASIHTTPRequest

How to implment laps in Stop Watch iphone app

拟墨画扇 提交于 2019-12-23 18:50:08
问题 I am building one application which has stop watch as its accessory function. I am trying to do something very similar to iOS stop watch. I got stop, reset functionality working but I could not get start (once it stop and user click on start) and lap functions working properly. I tried to look around for this problem but I could not find anything besides one time start and reset stop watch tutorials.Here is what I have right now. Can anyone help me out here with this functions ? // Stop Watch

empty NSDatePicker

大城市里の小女人 提交于 2019-12-23 15:50:07
问题 Hi Is it possible to have a NSDatePicker representing a nil object? Something like -/-/- or any other way. Thanks, Radu 回答1: Short answer: No NSDatePicker simply ignores invalid dates and nil. For example, this does not update the NSDatePicker, the old value remains: [datePicker setDateValue:nil]; Only solution: Detect nil and do something specific: if(date == nil) { // Set Specific Date NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyyMMdd"];

Swift countdown timer labels for Days/Hours/Minutes/Seconds

风格不统一 提交于 2019-12-23 10:39:38
问题 I'm creating a countdown timer that counts down to an NSDate set in a UIDatePicker . I have a label that shows the date we're counting down to and that works fine. What I'm also trying to add is labels for the number of whole days left and number of hours/minutes/seconds left in the current day (i.e. never more than 23/59/59) Here's what I've done at the minute but it obviously shows the values for the whole countdown. Hoping someone can help me work out the correct logic here. let

Ordinary Date Format “13th June 2007” in Swift [duplicate]

拜拜、爱过 提交于 2019-12-23 10:26:15
问题 This question already has answers here : Ordinal Month-day Suffix Option for NSDateFormatter setDateFormat (15 answers) Closed 3 years ago . hello can any one point me to hoe make a date format that looks like this: 13th June 2007. Notice the day has the word "th". I want to add that in my format. Thanks! 回答1: Updated for Swift 3 You can do something like this which is locale safe. let calendar = Calendar.current let date = Date() let dateComponents = calendar.component(.day, from: date) let

How can I change a label with a date once the system date changes in iOS?

99封情书 提交于 2019-12-23 09:59:33
问题 I have a simple query but don't know how to do it. This is what I am trying to achieve: 1) I have a UILabel with todays date i.e. "29/04/12" 2) At midnight I want that label to update by itself to "30/04/12" without needing to change view or press anything. It's step 2 that I don't know how to do. I have idea's of how it would be done such as potentially getting a system notification of the date change (if this is even possible) or using some sort of timer as a trigger. Any help would be

NSDateComponents: difference between weekOfYear and weekOfMonth

泄露秘密 提交于 2019-12-23 08:48:30
问题 In my app, I have to set up a weekly reminder so that an alert goes off at the same day/time, a week from now. I have been using NSDateComponenents.week = 1 and adding that to an NSDate, using NSCalendar's dateByAddingComponents:toDate:options: API. It seems that week is now being deprecated in iOS7, and the warning tells me to "Use weekOfMonth or weekOfYear, depending on which you mean". But I can't find much documentation about what either of them means. Can anyone explain the difference

Number of days in given year using iPhone SDK?

时光毁灭记忆、已成空白 提交于 2019-12-23 08:30:10
问题 I'm trying to get the number of days in a current year. When I try the solution on Number of days in the current month using iPhone SDK?, and replace NSMonthCalendarUnit by NSYearCalendarUnit, I still get the number of days for that month. Does anyone know how I should do this? Thanks in advance for your help. 回答1: Here's a super accurate NSCalendar extension in Swift 2: extension NSCalendar { func daysInYear(date: NSDate = NSDate()) -> Int? { let year = components([NSCalendarUnit.Year],

Date._unconditionallyBridgeFromObjectiveC(NSDate?) crash in Swift 3

旧城冷巷雨未停 提交于 2019-12-23 07:38:58
问题 I have following function in a swift file. I am calling this from Obj C file with NSDate in place of startDate. And quite often, not every time, my app crashes with Date._unconditionallyBridgeFromObjectiveC(NSDate?) How can I fix this? func trackMeetingEnded(_ name: String, startDate: Date, backgroundTime: TimeInterval) {} Stack trace Crashed: com.apple.main-thread 0 libswiftFoundation.dylib 0x102061e98 static Date._unconditionallyBridgeFromObjectiveC(NSDate?) -> Date + 72 1 Acid 0x10017ece4