Swift uses Jspatch essentials:
The Swift class inherits from the NSObject, its methods that inherit from the parent class are dynamic, other custom methods and properties need to be modified to be dynamic (except for the public property) example
1. Build a OC project named Swiftoc.:2. Create a new Swfit file named Test.swift, you will be prompted to select the Create bridging Header to establish a bridging file, the system will establish a "project name-bridging-header.h":3. Configuration
This error occurs when you use Cocoapod to import a swift third-party:[!] Pods written in Swift can is only integrated as frameworks; Add ' use_frameworks! ' to your podfile or target to opt-in using it. The Swift Pod being used is: three-party
1. Init (coder:)It is the default initialization function for the view controller to create an instance from the storyboard.(It is the initializer-uiviewcontroller instances created from a storyboard.)It is called only 1 times throughout the life
Swift-Add Pure AlamofireIf you have a neat code and can't tolerate any extra stuff, keep looking down.1. Download alamofire (https://github.com/Alamofire/Alamofire)2. Unzip and open alamofire.xcworkspace3. Delete unnecessary content (depending on
string*Swift's string type is seamlessly bridged with the Foundation NSString class*the strings in the OC language are also terminated with a, Swift is not*The string in OC is an object, and Swift uses string as a struct, which is more efficient and
/*: Functions: * functions are separate blocks of code that are used to accomplish a particular task. You give a function a proper name to identify what the function does, and when the function needs to be executed, the name is used to "invoke" the
Swift provides a C language-like Process Control structure (if/switch/for/while/dowhile) Branch if* only BOOL as conditional statement * conditional statement does not need to add ()* {} cannot omit * The mode of the IF branch in Swift can use the
Collection array
The array uses the [] definition, which is the same as OC
//: [Int]let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Traverse
for num in numbers { print(num)}
Get the specified item content by
//Override point for customization after application launch.// Initialize window, size is device physical size self. Window = UIWindow(frame: uiscreen. Mainscreen(). Bounds) // change the background color of window to white self.
In OBJC you can't put a non-object type into an array, you have to "Marshal" it and then put it in the array.In Swift you can easily put non-object types into an array:let ary = [1,2,3]You can explicitly specify the element type:let ary:[Int] = [1,2,
A method that needs to extend a string classExtension string { func Transformtopinyin ()-string {let mutablestring = nsmutablestring (string:self) //convert kanji to pinyin Cfstringtransform (mutablestring, Nil,
Required init? (Coder Adecoder:nscoder)can fail the constructor
Add a question mark (init?) following the INIT keyword.The fail constructor creates an object of an optional type of type. You can use the return nil statement to indicate
The two implementations of OC and Swift are largely indistinguishable, mainly in the way that some objects or methods are called differentlyOC Code Style:Self.view.backgroundColor = [Uicolor blackcolor];Loading a grainy spark pictureCaemitterlayer
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