Import Foundation
class Yjnetworkmanager:nsobject {
/** to
determine network type
-Returns: return value string WiFi (Kreachableviawifi) mobile network (Kreachableviawwan) no Network (knotreachable)
*/
class Func
Enumeration in the C language, the value of an enumeration can only be a number, and in swift the value of the enumeration is called raw value and can be represented by string, Character, Int, float, and so on.
Enum MyEnum {
}
For example: The enum
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
One, the compiler's several symbols to be easy to debug
#file--> contains the path to this symbol file
#function--> The name of the method that contains this symbol
#line--> Line number
Ii. generating random numbers in a certain range
Func
First, the circular statement 1. For loop
1) for-in cycle, for each element in the data range, sequence, set, etc., is executed once
For a In 0...5{}//loop iteration, from A=0 to A=5, execute {} code Note: A loop exists, that is, {}a does not
The swift language uses VAR to define variables, but unlike other languages, Swift does not automatically assign an initial value to a variable, which means that the variable does not have a default value, so it must be initialized before it is
The string interception in Swift is not as convenient as using NSString, because the method substring (from: ) required by string is not of type int, This is inconvenient at the time of use, here I wrote a extension to string, the usage is very
var Alert:uialertview = uialertview.init (title: "Public Security entry and exit online platform", Message: "At present you can use the web version of the Immigration business reservation and inquiry, whether to enter the public security entry and
The way you write it, you can only use it as a summary of your own Swift learning.
Import UIKit
Typealias block = (string,string) ()
Class Movecarviewcontroller:uiviewcontroller,mamapviewdelegate,amaplocationmanagerdelegate,amapsearchdelegate,
: Playground-noun:a place where people can play
Import UIKit
Ordered collection
var str = "Hello, playground"
var array1:array = array ()
var array2: [Int] = Array1
var array3 = Array2
Array1.count
If array1.isempty{
Print ("Kong");
}
var
Guard statement
A guard statement is a bit similar to an if statement, and is determined by the Boolean value of the expression after its keyword to decide what to do next. But unlike the IF statement, the guard statement will have only one block
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
1 when defining a model property, if it is an object, it is usually optional (create it when needed, avoid writing the constructor, simplify the code)2 If it is a basic data type, cannot be set to optional, and to set the initial value, otherwise
The first step is to set up the environment. I am an Apple system, and I am a poor boy. 8 K computers are far away from me. I am a black apple by myself. The total price is 1 K. I just need to learn enough. During this period, I learned a lot. That
Note: As the basic part has been roughly described in swift tour, the explanation does not reach 100% of the original meaning.
Constants and variables constants and variables
Both constants and variables need to declare names and types (as
The added type in swift: tuple (tuples) allows you to create or transmit a group of data,
For example, when you return a function value, you can use a single tuple to return multiple values.
The optional (Optional) Type is added to swift to
3. conditional statements
It is often necessary to execute different codes according to different situations. You may want to execute an extra code when an error occurs, or output it to a value that is too high or too low. To meet these requirements,
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