Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to get the day of summer at 68 16℃ by using Swift language under iOS?
How to get the day of summer at 68 16℃ by using Swift language under iOS?
As a novice iOS programmer with C# tailoring, I was devastated to see Swift's "complicated and changeable" grammar. Obviously, I think Apple is a particularly irresponsible company, and its grammar is changing. Is it interesting? Almost every Beta version of XCode 6 is accompanied by changes in Swift syntax. Pay tribute to the students who bought the Swift physical book online, because you will find that when you get the book, the grammar will change and you will feel very scratching your head.

Then there is the spit on Swift. ...

I won't spit if there are few basic APIs in the system. Many functions only need to be clicked. NET platform needs to be implemented under iOS. For example, the one to be shared today is obviously an attribute of type DateTime, okay?

Strong, standard strong, super strong, strong enough. What can I say? Although C# is also a strongly typed language, there is a great god of implicit type conversion in the world of C#. For the basic operations among Int, Int32 and Int64, type conversion is needed, which is estimated that Java does not need it. You may need C and C++, but I haven't learned this thing at all.

No exception handling. Not without it. The reason may be that Swift is immature. I found a class related to exception handling, but I don't know how to throw an exception. There seems to be no keyword to support this operation at present.

Speak calmly ...

Compared with Objective-C, Swift is a language that can be roughly understood. Probably a mixture of n languages. But it is much better than objective-C.

There is no distinction between public members and private members in Swift language, so in the world of Swift and Objective-C, all class members are * * *. I think what Swift copied. NET is its extension. Extension is like an extension method, isn't it?

In the video of Geek College, the lecturer told us that we can use extensions to realize the function of namespaces. But code compilation will become extremely slow. Do you build it? This situation directly led to my transplant. Net framework source code to Swift. By the way, the Swift language can't be compiled into the static library of Cocoatoouch for the time being. Compiler error, I don't know when it will be fixed ... and so on? But XCode 6.0. 1 came out ~

Text theory

I wrote this article just to enjoy the code. If it's for Mao, it's a spit ... OK, that's it, then I'll code it. ...

Rapidly occurring

Extended NSDate {

func day ofweek()-& gt; Int {

var interval = self . timeintervalsince 1970;

var days = Int(interval/86400);

Return (day 3)% 7;

}

}

I don't know if you can understand how excited I am to see that the editor of my blog can insert Swift code and highlight grammar. WordPress is really a tough guy among tough guys.

The use method is simple. Put the above code into your program, then instantiate an NSDate and call its dayOfWeek method.

Rapidly occurring

var dt = ns date();

var week = dt.dayOfWeek()

Week represents plastic surgery, and 0 to 6 represent Sunday to Saturday respectively.