nsdate

NSDate delay date change

扶醉桌前 提交于 2019-12-02 04:09:49
This is probably a simple solution but does anyone know how to delay the NSDate change past midnight? Any insight would be really helpful, thanks! Edit: I am currently getting the date this way and displaying a locations data based on that day. But, much like the NSDate is logically supposed to work, it switches to the next day at midnight. I want the date to change at 3am instead of at 12am. NSDateFormatter *f = [[NSDateFormatter alloc] init]; [f setDateFormat:@"EEEE"]; today = [f stringFromDate:[NSDate date]]; Should I just use the time instead of using NSDate? I am a bit of a noob to iOS so

How to sort the Array that contains date in strings in descending order? [duplicate]

≯℡__Kan透↙ 提交于 2019-12-02 04:04:17
This question already has an answer here: NSDateFormatter return incorrect date from string 3 answers I want to sort the array that contains date string in descending order, I have tried SO answers, but I am getting wrong output. Please see my code as below: NSArray *dateArray=[NSArray arrayWithObjects:@"01/12/2012",@"01/26/2011",@"02/09/2005",@"02/24/2006",@"03/19/2007",@"07/14/2011",@"08/17/2007",@"10/04/2007",@"10/31/2006",@"12/05/2012",@"12/06/2006",@"12/23/2008",nil]; NSDateFormatter *formatter=[[NSDateFormatter alloc]init]; [formatter setDateFormat:@"MM/DD/YYYY"]; NSMutableArray *tempArr

Is it possible to check when user downloaded my ios app? [duplicate]

浪子不回头ぞ 提交于 2019-12-02 03:55:04
问题 This question already has answers here : Change paid app to free but know if user previously purchased it (7 answers) Closed 5 years ago . Is it possible to check when the user downloaded my iOs app, and if so, is it possible to make a if statement out of it like: if(downloadDate>1march) { } sorry if you think the question is bad... any code would be greately appreciated though :D should also probably mention that my app has been on the AppStore for six months... 回答1: I'm not sure if there's

Converting NSDate to NSString causes unrecognized selector exception

廉价感情. 提交于 2019-12-02 03:45:27
I am storing an NSDate in a plist as a string, and at launch I am trying to convert the string from the plist back to an NSDate to compare it later. This is how I am storing the value in my plist: [InfoDic setValue:[NSDate date] forKey:@"LastDate"]; In the log (When I convert the [NSDate date] to a proper string) it says this: 2013-04-13 22:47:57 +0000 This is how I am trying to convert the plist value back to an NSDate : NSString *Checkdate= [InfoDic objectForKey:@"LastDate"]; NSDateFormatter *DateFormat=[[NSDateFormatter alloc]init]; [DateFormat setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss

NSDateComponents weekOfYear returns wrong value

别来无恙 提交于 2019-12-02 03:38:01
问题 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierISO8601]; [calendar setTimeZone:[NSTimeZone defaultTimeZone]]; [calendar setFirstWeekday:2]; [calendar setMinimumDaysInFirstWeek:1]; NSDateComponents *mockTodayComponents = [[NSDateComponents alloc] init]; mockTodayComponents.day = 28; mockTodayComponents.month = 12; mockTodayComponents.year = 2015; NSDate *date = [calendar dateFromComponents:mockTodayComponents]; NSDateComponents *c = [calendar

Convert date format in returns wrong date xcode [duplicate]

社会主义新天地 提交于 2019-12-02 03:29:31
This question already has an answer here: NSDateFormatter show wrong year 1 answer I want to convert date from 23 May, 2017 to 23-05-2017 . I have tried with the following code but it returns 25-12-2016 . NSDateFormatter *oldFormatter = [NSDateFormatter new]; [oldFormatter setDateFormat:@"dd MMM, YYYY"]; NSDate *oldDate = [oldFormatter dateFromString:dateStr]; NSDateFormatter *newFormatter = [NSDateFormatter new]; [newFormatter setDateFormat:@"dd-MM-YYYY"]; I am using Xcode 8.2.1. Thank You. You need to do below changes: YYYY --> yyyy Updated Code: NSString *strInputDateString = @"23 May, 2017

NSDate initWithString

心不动则不痛 提交于 2019-12-02 02:31:23
问题 After updating Xcode to version 4.2 I received the following warning in my current project: warning: 'NSDate' may not respond to 'initWithString:' What must I do? :) 回答1: This method is in the documentation only noted at the Mac OSX page, not the iOS. Why Apple has different versions is unclear to me, but they luckily respond the same. Because the class reference for iOS says there is no such method for iOS NSDate, you get the warning. Your code, however, will respond perfectly fine. To

NSDate initWithString

爷,独闯天下 提交于 2019-12-02 02:19:43
After updating Xcode to version 4.2 I received the following warning in my current project: warning: 'NSDate' may not respond to 'initWithString:' What must I do? :) This method is in the documentation only noted at the Mac OSX page, not the iOS. Why Apple has different versions is unclear to me, but they luckily respond the same. Because the class reference for iOS says there is no such method for iOS NSDate, you get the warning. Your code, however, will respond perfectly fine. To silence the warning, you should indeed use NSDateFormatter. Regards, Jacco You should use NSDateFormatter to get

Sending NSCFCalendar nil NSDate Sarcastic Error [closed]

一曲冷凌霜 提交于 2019-12-02 02:04:30
A few threads here discuss the new iOS 6 Xcode error that pops up in the console when sending nil dates to Calendar methods: -[__NSCFCalendar components:fromDate:toDate:options:]: fromDate cannot be nil I mean really, what do you think that operation is supposed to mean with a nil fromDate? An exception has been avoided for now. A few of these errors are going to be reported with this complaint, then further violations will simply silently do whatever random thing results from the nil. The error made me chuckle a bit, but got me to thinking.... The code I've written that results in this error

Get the exact difference between 2 dates for a single NSDateComponent

元气小坏坏 提交于 2019-12-02 00:57:24
问题 How can I get the exact difference (in decimal) between 2 values of NSDate . Eg. Jan 15 2016 to Jul 15 2017 = 1.5 Years . I can use something like: NSCalendar.currentCalendar().components(NSCalendarUnit.CalendarUnitYear, fromDate: date1, toDate: date1, options: nil).year but this gives me absolute values . i.e. for above example it would give me 1 Year . Is it possible to get exact values correct to at least a few decimal places? 回答1: The terms you've used here are misleading. When you say