1. Swift enumerates basic conceptsThe enumeration in Swift is more powerful than the enumeration in OC, because the enumeration in Swift is a first-class type.
It can add properties and methods like classes and structs
format:
Enum method{Case
Let slider = UISlider (Frame:cgrectmake (10.0,10.0, Cgrectgetwidth (self.view.bounds)-10.0 * 2), 20.0
) Self.view.addSubview (slider)
slider.backgroundcolor = Uicolor.lightgraycolor ()
Set value (the default value is 0.0 and the value range is 0.0~1
The graph given by the UI requires the status bar to use bright colors because the background color is highlighted
But actually the default is black
There are two ways to use this:
1. Operation Appdelegate
1 Add view-controller-based status
Blog.csdn.net/lzueclipse/article/details/26405753#1536434-qzone-1-61807-cac534f6a16e831f54c45c717ec6acf9Deploy the OpenStack Swift development environment--saio-swift All in one, encounter problems and resolve-stick to learning lzueclipse a small
Get Imagefunc Fimage (_ imagename:string), UIImage { return UIImage (named:imagename)!} Get URL Urlfunc FUrl (_ urlstring:string)? { return URL (string:urlstring)}//authentication is the format of the phone number func isphone
The subscript script can be defined in the class, structure, and enumeration targets, allowing these types of instances to access attributes and methods quickly through. Subscript (Index: INT)-> int {get {// return the int type value that matches
Affiliated scripts
Affiliated scriptsObjects such as class, structure, and enumeration can be considered as shortcuts to access objects, sets, or sequences, you do not need to call the instance's specific assignment and access methods. For example,
Nonsense
After the previous article was published, some garden friends said that after the first article was published, cucumber dishes were all cool. I think it was indeed, and there were indeed a large number of articles in 100, at present,
In the WWDC demonstration, we can see that swift, a language closer to the script, can use less code to complete the same functions as OC. However, for those who study war in war like me, every day they hold Big headers like swift programming
Attributes and constants
If an instance with a struct is created and assigned a constant, no attributes of the instance can be modified:
let rangeOfFourItems = FixedLengthRange(firstValue: 0, length: 4)rangeOfFourItems.firstValue = 6
When an
// ==================================// 2014/7/21 27 swift collection// ==================================
Swift provides two set types: arrays and dictionaryies. Both sets are variable and can be added, deleted, and modified after the set is
Basics:
Constants and variables
Note
Semicolon
Integer
Floating Point Number
Type security and type inference
Numeric literal
Numeric type conversion
Type alias
Boolean Value
Tuples
Optional
Assertions
Declare constants and
1: Hello World
import Foundationprintln("hello world")
In this way, a piece of code can print out Hello world without adding ";" if you add ";", it can also run. It seems that it is to avoid the trouble. It is no longer like the C language. ";" is
SWIFT is a new object-oriented programming language for iOS and OS X development. SWIFT is modern, powerful, and easy to use. this is the first message from SWIFT on Apple's official website. Swift is an object-oriented programming language for iOS
Recently, when answering the stackoverflow question, we found that the javasmselector method was removed in swift, and Apple commented that this method was removed because it was not safe:
NOTEThe performSelector: method and related
From this chapter, most of the important content of the SWIFT programming language guide is the concept, and the code is not too much. Understanding Swift's object-oriented philosophy, syntax, and class structure, and constructing the structure
1. during actual compilation, the swift compiler optimizes the use of strings so that the actual replication only occurs when absolutely necessary, this means that when you use a string as a value type, you can achieve extremely high performance.
2
1. // The following floating point literal values are equal to 12.1875 in decimal format:
let decimalDouble = 12.1875let exponentDouble = 1.21875e1let hexadecimalDouble = 0xC.3p0//==12+3*(1/16)
2. // type alias. Use the typealias keyword to define
1.
2. newsviewcontroller. Swift
/// Newsviewcontroller. swift // navigationdemo /// created by Zhao Chao on 14-6-27. // copyright (c) 2014 Zhao Chao. all rights reserved. // import uikitclass newsviewcontroller: uiviewcontroller {override func
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.