0

So, I am kinda new to programming, and I am learning the right way to do things. I am actually getting kind of excited because I am actually starting to understand how people find the information they need when making an app for apple or any company. Here is my question. I was just surfing around the website which explains the multiple classes that come with XCode and I found myself wanting to test if I could do different things with time in my app. Apple has a package for this called Foundation and in that package they have a class called NSTimeZone, not sure why each class has the NS prefix before every word, so if someone could explain that I would be grateful. So, In NSTimeZone they have a boolean check called isDaylightSavingsTime

https://developer.apple.com/reference/foundation/nstimezone/1387191-isdaylightsavingtime

It can be found right there. So I went to work and started messing with this class in XCode Playgrounds. The only problem is I don't know how to use this boolean value. I tried to do this...

    var currentDate = NSDate.init()
var daylightsave: Bool = NSTimeZone.isDaylightSavingTime(for: currentDate)
var daylightsave: Bool = NSTimeZone.isDaylightSavingTime(NSTimeZone)

and many other things but nothing seems to work. I am trying to comprehend this so that I can better understand programming as a whole, and how to read and understand class documentation. If anyone has any Insight on this subject and can help feel free to comment. Please don't bash me I understand that this code may be wrong. I am trying to learn so let me know what's wrong.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Devin Tripp
  • 147
  • 10
  • 1
    @LeoDabus That does answer my question, and I am using Swift 3. One more thing though what does the ?? "" mean at the end of a return statement. Sometimes that is put at the end I don't know what it means – Devin Tripp Jan 28 '17 at 03:32
  • `?? ""` means nil coalescing operator. it returns a default value (empty string) in case of nil – Leo Dabus Jan 28 '17 at 03:33
  • If you are using Swift 3 you should use the `TimeZone` class, not `NSTimeZone`. – rmaddy Jan 28 '17 at 03:52
  • And if you want to know what a given Swift operator is, please reference ["The Swift Programming Language"](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/) book. – rmaddy Jan 28 '17 at 03:53

0 Answers0