What can I do for 1 months in my spare time?

Source: Internet
Author: User
Tags assert modifier

Leave your own memory, give yourself some pressure, and give yourself some motivation.

Target: Learn swift in 1 months and use Swift to reconstruct the Silver Cash Express line.


Read the Open source project
A. Function tag:
(1) Override Func (duplicate, Reload)
Delegate: Overloaded method
Example:
Override Func Viewdidload () {
Super.viewdidload ()

View.backgroundcolor = Uicolor.hexint (0xf3f3f3)

Set empty view picture
nodataimg = UIImage (named: "Nodata_play_history")

Set empty view state
Configemptstatus ()
}




(2) Escaping escape function closure equivalent to block


(3) whether the as-type conversion is the same type or subclass to the left of the as right


(4) fileprivate let (file private) is equivalent to the macro definition of the current file, which defines a global string macro
Private: Proprietary properties and methods that are accessible only in the current class and do not include classifications;
Fileprivate: Private properties and methods within a file that can be accessed only in the current file, including different classes in the same file.




(5) Lazy var (lazy loading)


(6) extension (extended)
Increase calculation instance properties and calculation type properties
Defining instance methods and type methods
Provide a new initializer
Define Subscript
Defining and using new built-in types
Let a type of existence obey a protocol


(7) required init () {}
1. The required modifier can only be used to decorate class initialization methods.
2. When a subclass contains an initialization method that is different from the parent class (the initialization method parameter type and number are different from the parent class), the subclass must implement the required initialization method of the parent class, and also use the required modifier instead of override.
3. When a subclass has no initialization method, it can not implement the required initialization method of the parent class.


(8) @IBOutlet weak Var (xib connect a control)


(9) Guard
As with the IF statement, Guard is also based on the Boolean value of an expression to determine whether a piece of code should be executed. Unlike the IF statement, the guard executes the code only when the condition is not satisfied. You can think of guard approximation as an assert, but you can gracefully exit rather than crash.
1. Check the conditions you expect, rather than what you expect. is similar to the Assert. If the condition does not conform, the else statement of the guard runs, which exits the function.
2. If the conditional judgment is passed, the variable of the optional type will be automatically disassembled in the range called by the Guard statement-in this case the range is inside the Fooguard function. This is a very important, but somewhat strange, feature, but it makes the guard statement very practical.
3. Check the situation you don't expect, making the function you write easier to read and easier to maintain.




(Didset willset) (KVO bottom)


(one) @objc func add tag because OC is the runtime demo,swift at compile time to decide related things, if need to run runtime runtime to get the Swift related class or function, need @objc identity decoration,,, Classes inheriting nsobject do not require @objc adornments, and the system automatically adds modifiers


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.