nsdate

Get time from remote server for ios app

血红的双手。 提交于 2019-12-06 07:21:34
问题 I would like to know how my iOS app can get the datetime from a distant server (NTP ? Other..?), and not with local iPad datetime ; and transform it on NSDate. Thanks 回答1: https://github.com/jbenet/ios-ntp seems to be a NTP framework for iOS which gives you [NSDate networkDate]; 来源: https://stackoverflow.com/questions/10851161/get-time-from-remote-server-for-ios-app

CoreData conditionally fetching on NSDate using NSPredicate (swift)

岁酱吖の 提交于 2019-12-06 06:52:50
问题 Basically I have an entity called TimeLoc that has three attributes: time, latitude and longitude. And their types are Date, Double and Double respectively. I got stuck when I was trying to make a request with filter on attribute time. Here is my code: ... var appDel: AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate) var context: NSManagedObjectContext = self.managedObjectContext! var request = NSFetchRequest(entityName: "TimeLoc") var endTime = NSDate() var startTime

Converting NSDate from a calendar to another

送分小仙女□ 提交于 2019-12-06 06:04:37
I'm having trouble here. Took me hours but no use. Please keep in mind I checked the heck of StackOverFlow for a fix but there isn't any. When I convert the _date Object from Gregorian to Hijri it does not convert. I know that because when I print it it still gives me the Gregorian day. This troubles me because I want to setDate of a UIDatePicker and it's setting it incorrectly because the _date is gregorian and my UIDatePicker object calendar set to setCalendar:_hijriCalendar //DATE SETTING _date = [NSDate date]; _hijriCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSIslamicCalendar

Is there a way to get Xcode's debugger to show dates in local timezone (i.e., not UTC)?

。_饼干妹妹 提交于 2019-12-06 05:56:01
问题 I'm trying to debug code that makes pretty heavy use of dates which has me comparing tons of different NSDate values in the debugger. The debugger is displaying those dates in UTC format--for example: date1 = (NSDate *) 0x01b11460 @"2012-02-15 18:55:00 +0000" It would be a lot easier for me if it would show them in my local timezone as that is what the test code I'm debugging seems to be using. I do have feeling that I'm missing something much more basic here so I'm hoping someone can

How to get All the sundays in Array of date ios

梦想与她 提交于 2019-12-06 05:39:49
问题 i just want an array who contain all the Mondays in the year in the form of NSDate but in swift. i am using the folowing code in the objective -c but dont know how to user it in swift. NSDate *pickerDate = [NSDate date]; NSLog(@"pickerDate: %@", pickerDate); NSDateComponents *dateComponents; NSCalendar *calendar = [NSCalendar currentCalendar]; dateComponents = [calendar components:NSWeekdayCalendarUnit fromDate:pickerDate]; NSInteger firstMondayOrdinal = 9 - [dateComponents weekday];

Which is this NSDateFormatter style Friday, December 18th

梦想与她 提交于 2019-12-06 05:13:39
问题 I want to know which is this date format Friday, December 18th and also is this standard date format or i have to some hard work to get this. Thanks. 回答1: I don't think the th is possible to achieve via formatters. Although you can do it like this: NSDate *today = [NSDate date]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"EEEE, MMMM d"]; NSString *dateString = [dateFormat stringFromDate:today]; NSCalendar *cal = [NSCalendar currentCalendar];

Swift : Checking if 2 NSDates are the same

半腔热情 提交于 2019-12-06 05:05:13
Really simple one, I am sure this is a bug in swift. I am trying to check if 2 NSDates are the same. This statement never passes even thought the printout is below println("\(statistics.startDate) \(healthObject.date)") if healthObject.date.isEqualToDate(statistics.startDate) { healthObject.flights = Int(quantity.doubleValueForUnit(HKUnit.countUnit())) println(Int(quantity.doubleValueForUnit(HKUnit.countUnit()))) } 2015-03-30 13:56:50 +0000 2015-03-30 13:56:50 +0000 2015-03-30 13:56:50 +0000 2015-03-31 13:56:50 +0000 2015-03-31 13:56:50 +0000 2015-03-30 13:56:50 +0000 2015-03-31 13:56:50 +0000

iPhone How to get image back from NSData

自古美人都是妖i 提交于 2019-12-06 05:00:37
问题 In my iPhone App I am storing image into NSData by UIImage *image =imageView.image; NSData *myData = UIImagePNGRepresentation(image); But How to get back "image" from " NSData " and I can display it again into in to UIImageView . Please Help and Suggest, Thanks. 回答1: have you tried +[UIImage imageWithData:] ? 回答2: UIImage *img=[UIImage imageWithData:data]; [yourImageView setImage:img]; 来源: https://stackoverflow.com/questions/4655174/iphone-how-to-get-image-back-from-nsdata

stringFromDate always NIL

对着背影说爱祢 提交于 2019-12-06 04:22:19
I know this is a repetitive question, but after searching for many similar questions on stackoverflow and google, none of the solutions worked for me. I am tring to convert date which I receive from DB to string format to display in iPhone app. I am converting date to string in following manner, but [dateFormat stringFromDate:beginDate] always return nil. NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"MMM dd hh:mm a"]; NSString *dateString = [dateFormat stringFromDate:beginDate]; NSLog(@"date: %@", dateString); [dateFormat release]; The server NSDate

In Objective-C, to get the current hour and minute as integers, we need to use NSDateComponents and NSCalendar?

落爺英雄遲暮 提交于 2019-12-06 03:54:59
问题 I'd like to get the current hour and minute as integers. So if right now is 3:16am, I'd like to get the two integers: 3 and 16. But it looks like [NSDate date] will give the number of seconds since 1970, or it can give a string of the current time representation, but there is no easy way to get them as integers? I see a post in Getting current time, but it involved NSDateComponents and NSCalendar ? That's way too complicated... all that was need is something like NSDate *date = [NSDate date];