The basic operations of the array in Swift are as follows:(1) Calculating the length of the array.(2) Determine if the array is empty.(3) An array of new elements。(4) Array merging。(5) Inserting elements into any position。(6) Delete an element at any location(7) Delete the last element of an array(8) Insert delete operation array cannot be crossedThe following actions are illegal:。(9) Modify a value in the array。(10) Bulk substitution of array element
:11.0111.0Welcome to follow Dongsheng Sina Weibo@tony_Dongsheng. Learn about the latest technical articles, books, tutorials and information on the public platform of the smart Jie classroom? More ProductsIOS,Cocos, mobile Design course please pay attention to the official website of Chi Jie Classroom:http://www.zhijieketang.comSmart-Jie Classroom Forum Website:http://51work6.com/forum.php Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
---Array, mainly used to save data, in Swift, the creation of arrays is more powerful than OC, but at the time of initialization, found a few problems, perhaps because of self-study reasons, through the search, reluctantly persuade themselves (mainly initializing the problem)As follows:var arr = ["abc", 123, 234.323] arr + = ["value"] Print(" appended array \(arr)") Results[ABC, 123, 234.323, AAA]Butvar mutableA2 = [] MutableA2 + = ["123"]
UiactivityindicatorviewUiactivityindicatorview ( activity Indicator) control, also known as the Loop progress bar, is the loading effect.Creation of Uiactivityindicatorview:(1) using Ctrl+drag drag-and-drop method in Stroyboard to create(2) Code creation:Let Activityindicator = Uiactivityindicatorview (ActivityIndicatorStyle:UIActivityIndicatorViewStyle.Gray) Activ Ityindicator.center=self.view.centeractivityindicator.backgroundcolor = Uicolor.greencolor () Activityindicator.startanimating ()//S
current objectSelf.init ()//execute to this self to allow access to the object's propertiesSelf.name =name}}
Destructors
Destruction of tracked objects
No func does not let the outside call
No () do not allow overloading
Called before the object is destroyed
Dealloc similar to OC
deinit { /* 1. Tracking object Destruction 2. Must be released -notification, no release will not crash, but will cause m
period of time. The code in the closure can access the variables and functions that are available in the scope created by the closure, even if the closures are performed in a different scope, as you've seen in the example of nested functions. You can use {} to create an anonymous function. Use in to detach parameters and return value type declarations from the closure function body Numbers. Map({ (number: int), int inlet result = 3*number; return result; })rewrite closures, return
Swift Learning -- use if and switch for conditional operations, and use for, while, and do-while for Loop
// Switch supports any type of data and various comparison operations-not only integers and test equality
// If the default program is removed, an error is returned.
let strings = "hello3"switch strings{ case "hello1": let stringsComment = "say hello1" println("stringsComment is \(stringsComm
tuples used in this use can be Tuple2.first tuple2.second Tuple3.thirdPrint ("Get the first value \ (Tuples2.first), get the second value \ (Tuples2.second), get the third value \ (Tuples2.third)" )This will cause an errorTuples2.first = "Test"; The let before tuple2 should be changed to Var to make tuples into variable tuplesvar tuples2 = (First: "Hello", Second: "World", third:2017)The values of the tuples used in this use can be Tuple2.first tuple2.second Tuple3.thirdvar print ("Get the firs
From the previous page to the next page of the value of the general use of attributes (relatively simple method of transmission), when the need to forward from the next page to the value, we generally think of the agent and block, of course, there is a singleton, today we learn how to use Swift to pass the valueWe start with the simplest attribute values and use the storyboardFirst pageClass Addressbookviewcontroller:uitableviewcontroller} }func Addin
(key,value) tuples, and they can be decomposed using temporary constants or variables. For (Airportcode, Airportname) in airports {println ("\ (Airportcode): \ (airportname)")We can also retrieve the key or value for a dictionary by accessing its keys or the Values property (both of which are ergodic collections) for Airportcode in Airports.keys {println ("Airport code: \ (Airportcode)")}For Airportname in Airports.values {println ("Airport name: \ (airportname)")If you just need to use a dicti
or keys to access elements. A comma is allowed after the last element.var shoppinglist = ["Catfish", "water", "tulips", "Blue paint"]SHOPPINGLIST[1] = "Bottle of Water"var occupations = ["Malcolm": "Captain","Keylee": "Machanic",]occupations["Jayne"] = "Public Relations"To create an empty array or dictionary, use the initialization syntax.Let Emptyarray = [String] ()Let emptydictionary = [String:float] ()If the type information can be inferred, you can use [] and [:] To create an empty array an
Enumerations are often used to implement certain functions for a particular class or struct. Similarly, enumerations can easily define a toolbar or struct to be used for a complex type. To implement this functionality, Swift allows you to define nested types, which define nested enumerations, classes, and structs in supported types.To nest another type within a type, write the definition of the nested type within {} of its outer type, and you can defi
Related informationStart developing iOS apps Now (start developing iOS apps today)Apple Development Chinese station CocoachinaSwift Development Official websiteIOS Developer LibraryThe Swift programming language Chinese Full versionInspector PanelView ControllerOnce you have built a basic view hierarchy, the next step is to control the visual elements and respond to user input. In an IOS application, you can use the view controller ( UIViewControll
? Keyle previously learned 1 weeks of OC, but OC Foundation is infinite approach to zero, the reason is OC's grammar is sang high Xin Big Bing on Kuang, now just work and then there are some scattered time to see Swift will be here to write down some learning experience, slow update in ...??
Harvest the first error when the first HelloWorld encountered a problem, I have a variable to make the followin
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.