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
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
Let string = "Click the Register button to signify that you have consented to the privacy Policy and the service agreement"Let Ranstr = "Consent"Let attrstring:nsmutableattributedstring = nsmutableattributedstring (string:string)Let str = nsstring
Swift Video Tutorial: Http://www.cocoachina.com/bbs/read.php?tid=204280Swift official Textbook pdf:http://www.cocoachina.com/bbs/read.php ? Tid=204446swift and OC Contrast series: http://www.cocoachina.com/bbs/read.php?tid=204294 ; http://
Reference Link: http://www.jianshu.com/p/eb718439551f1 defer syntaxDefer is a new syntax statement added to Swift2.0. defer The meaning of delay and delay.The syntax for defer is as follows:// Do something }Add deferred-processing code in
This article simply introduces the use of the delegate method of the value of the transfer, changing the font size and color of the previous interfaceFirst create a Navigation view:Let VIEWC = Viewcontroller ();Let Navigationc =
1 identifiersNames named for variables, constants, functions, structs, classes, enumerations, methods, protocols, etc. in a programYou can use any character as a named identifier, but you have the following naming convention:(1) Case-sensitive(2)
Swift interacts with OCSOURCE please click on GitHub address to download.Main functions:
1. In the OC Project:
1.1.OC code calls Swift method
The 1.2.Swift code calls the OC code.
2. In the SWIFT project:
Because Swift operates at a high level and has to work with OBJC, programs written in Swift are generally handled by the OBJC and Swift runtimes. Because Swift's nature-in other words, it's a static language- The SWIFT runtime differs greatly in
Perhaps you have some questions about the origin of the famous NS prefix.The vast majority of these NS-prefixed classes are part of the foundation framework in the NeXTSTEP operating system, which is the basis of OS X.NEXTSTEP programmers use NX
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,
Sorting algorithms are often used, such as: bubbling, selection, quick sorting, binary insertion sorting, and so on. The front two does not say, paste out their own quick sort and binary insert sort of swift and Java code implementation, like the
@objc protocol Transaction { func commit() -> Bool optional func isComplete() -> Bool }The above protocol is marked as the @objc attribute, making it compatible with OBJECTIVE-C code. This is necessary if the Protocol has an optional protocol
iOS 8 after the official Apple recommended the use of Uialertcontroller this class, so specifically to find information online, understand the usage, write a code, record!Thank you, turn from: http://www.hangge.com/blog/cache/detail_651.html1.
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.