[Swift-Summary] basic usage, swift-summary basisDeclare variables and constants
// Use var to declare a variable var str = "Hello, playground" str = "Hello world"; // use let to declare a constant let str1 = "I Am a handsome guy "; str1 = "I'm not a handsome guy"; // the following error will be reported: let name = "I Am a handsome guy"; // declare a constant and the type is automatically inferred as String
A: children's programming is not good!
B: most of them do not like learning. Starting from reading the English version, you will fall in love with programming!
Type aliases type redefinition (typedef)
The keyword of the type that is redefined in SWIFT is typealias. As for how to use it, you don't have to talk about it. Let's look at the example:
Typealias audiosample = uint16 // a type name audiosample is defined, representing the uint16 type var ma
chapter will cover. You can also use string values wherever you need to use the NSString object.1. String literalsYou can use string literals to define string literals. The string literal is a fixed text string enclosed by a double argument.String literals can be used to provide initial values for constants or variables let somestring = "a string literal";Note Swift can tell that the constant somestring is a string type, because we used string litera
Boolean value
Swift has a basic Boolean type, called Boolean (bool), and a Boolean value called a logical value (logical), because it can only be true (true) or False (false). Swift provides two Boolean constant values: True,false:
1 Let orangesareorange (oranges are oranges) = True2 Let turnipsaredelicious (turnip is delicious) = False
Orangesareorange and Turnipsaredelicious are inferred as Boolean typ
[Swift] learning notes (1) -- getting started with basic data types, code styles, tuples, assertions, and swift learning notes
Since Apple released swift, I have been trying to learn about it and have never been fully involved in it. From today on, I will use blogs to drive my swift learning, it is also faster for ever
Hybrid programming in Apple system development (2): mutual calls between Swift and C, system development swiftWhen performing mutual calls between Swift and C, it is necessary to first understand the type conversion relationship between the two languages:
C type
Swift type
Bool
CBool
Char, signed char
CChar
Unsigned ch
For Swift to learn, there must be a development environment. Simply put your Xcode mac system in the right way. So let's take a quick look at what's going on here.1.1 Download XcodeXcode is Apple's programming tool, similar to the Microsoft-produced Visual Studio, which writes Java Eclipse and develops flash IDE. So-called 工欲善其事 its prerequisite, so the first thing we need to know is where to download Xcode, there are several ways.Route One: Via AppSt
The main things to see today are the basic operators in Swift. Record it.Null-value merge operator (Nil coalescing Operator)a ?? bIn the??is a null-value merge operator thataBe judged, if not fornilThe package is unpacked, otherwise it returnsb。The following two points are required when using:-A must be optional.-B must be consistent with type aIn other words, a must have the possibility of being prepared tires, B must have to do the preparation of th
How to get started with Apple's Swift programming language (Chinese version) 2. How to get started with swift
Apple Swift programming language tutorial [Chinese version]
Directory
1 Overview
2 Swift getting started
3 simple value
4 control flow
5. Functions and closures
6 objects and Classes
7 enumeration and Struct
Original blog. Reprint please indicate the sourceIn the recent write code with Swift, despite some problems, but the amount of code has really lost a lot.Swfit Novice Tutorial Series will continue to fix the update as I accumulate in the SwfitPrevious tutorialsSwift Single-instance mode specific explanation-thread safety, multi-core performanceSwift Novice Tutorial 4-collection (array,dictionary)Swift Novic
jump out of switch.In the for-in syntax, you can access each entry in the dictionary in the form of a key-value pair (that is, traversing the dictionary).Let interestingnumbers = ["Prime": [2, 3, 5, 7, 11, 13],"Fibonacci": [1, 1, 2, 3, 5, 8],"Square": [1, 4, 9, 16, 25],]var largest = 0For (kind, numbers) in Interestingnumbers {For number in numbers {If number > largest {largest = number}}}Largest Experiment//Exercises ADD another variable to keep track of which kind of number is the largest,
1.swift Create TableView Two classes Viewcontroller and Secondviewcontroller in this example2. Create a navigation bar in Appdelegate, initialize with the view Code 1 func application (application:uiapplication, Didfinishlaunchingwithoptions launchoptions: [Nsobject:anyobject]?) -> Bool { 2 // Override point for customization after application launch. 3 let Vc:viewcontroller = Viewcontroller () 4 let NAVIGATIONVC = Uinavigationcontroller (r OOTV
Infix syntax is a kind of OC Ritter, which is to add an explanatory word to the arguments of the function, so that the meaning of the parameter is understood when the call is made.Like what:-(void) Processdatawithparamaa: (NSString *) Paramaa paramab: (NSString *) paramab{}When called: [Self Processdatawithparamaa:@ "A" paramab:@ "B"];But you find that, this infix syntax is the premise that you must be in the first name of the function, write a with what the name of a parameter, or the first
The most classic example of learning a new language is the output "Hello world! ”Print ("Hello world! ") This is how swift is exported.If you have used other languages, then it seems to be very familiar. But it's a lot easier than some c.1, do not need to import some separate libraries, such as input/output or string processing function of the class library,2. Code that does not need to be written at the global scope is used as an entry point program
Optionals Selection
The selection (as if not translated in this way) is applicable to situations where values may be null. There are two options for one selection: The value is equal to or equal to X, or the value does not exist.
The concept of selection is not in OC and C. The closest concept in OC is that the return value in OC is the function of the object. If the object does not exist, nil can be returned, however, nil can only represent objects. It cannot represent basic types, struct type
Swift 2.0 Study Notes (Day 13)-integer and floating-point data types, swift Study Notes
For Original Articles, please reprint them. Reprinted Please note: Guan Dongsheng's blog
Swift provides 8, 16, 32, and 64-Bit Signed and unsigned integers. These integer types follow the naming conventions of the C language. I have summarized the integer types in
Swift protocol and swift Protocol
The protocol in Swift is also called in object-c, but in other languages it may be called Interface (such as java) or pure virtual function. In fact, it all means.
The Protocol is mainly used to define uniform methods and attribute names, but does not implement any functions. Only the classes that implement the Protocol need to i
Swift custom control-input box and swift control input box
When developing Android projects, common functions are often encapsulated into controls. One is to reduce the amount of code, the other looks concise, and Apple development also prefers to encapsulate them into controls, then drag and drop in the storyboard. for IOS development, the code quality is not very high because it belongs to the cainiao lev
Swift string search and Swift string SEARCH
Var test = "11111111111 test"
If (string. rangeOfString ("test ")! = Nil) // note! = Left and right Spaces
{
Println ("find ")
}
If you want to obtain the location, you can:
Var t = string. rangeOfString ("test ")
Start position
T ?. StartIndex
End position
T ?. EndIndex
In addition, add a method, google's
Let string = "hello
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.