Examples of methods and traversal methods for defining two-dimensional arrays in Swift
Updated: July 4, 2015 16:02:26 Submission: junjie
This article mainly introduces the method and traversal method examples of defining two-dimensional arrays in Swift. This article directly gives code examples. Friends who need it can refer to it.
//Definition method onevar array1 = [[Int]]() //Definition method twovar array2 = Array<Array<Int>>() array1 = [ [13,1,4], [5,1,7,6] ] array2 = array1 // Definition of one-dimensional arrayvar v = [Int]() v = [4,5,7,8] (v) println(array1) println(array2) //Array traversalfor var i=0; i<; i++ { for var j=0; j<array1[i].count; j++ { println(array1[i][j]) } }
Related Articles
Simple analysis of some basic features of Swift language
This article mainly introduces some basic features of Swift language. This article talks about the most basic classes and objects in each language. Friends who need it can refer to it.2015-07-07Test UIAlertController method in Swift
This article mainly introduces the method of testing UIAlertController in Swift. Friends who need it can refer to it2015-10-10Case Study on Data Types Supported by Switch Loop
This article mainly introduces the data types supported by switch loops. This article explains it in detail through actual cases and has certain reference value for everyone's study or work. Friends who need it can refer to it.2020-06-06Use UICollectionView to implement long press and drag function under Swift
Drag and drop sorting is a must-have interactive design for news apps, such as Toutiao, NetEase News, etc. This article mainly introduces the long press and drag function of using UICollectionView under Swift. Friends who need it can refer to it.2017-03-03Detailed explanation of the automatic archive and decomposition of NSCoding in swift
This article mainly introduces the automatic archiving and de-archiving of NSCoding in swift, which has certain reference value. Interested friends can refer to it.2017-03-03Swift How to make ScrollView scroll to a specific location
This article mainly introduces how Swift can scroll ScrollView to a specific location. This article introduces you very detailed through sample code, which has certain reference value for your study or work. Friends who need it can refer to it.2023-07-07Swift 4.1 transition animation achieves side-sliding drawer effect
This article mainly introduces the Swift 4.1 transition animation to achieve the side-sliding drawer effect, which has certain reference value. Interested friends can refer to it.2019-06-06IOS implements simple barrage function
This article mainly introduces the implementation of barrage functions in IOS. Here is an example to show barrage functions. Friends who need it can refer to it.2016-07-07Guide to how to use arrays in Swift programming
This article mainly introduces the guide to using arrays in Swift programming, which is the basic knowledge in Swift introduction learning. Friends who need it can refer to it.2015-11-11Example of usage of Notification Center in Swift
This article mainly introduces you to the relevant information about the use of Notification Center in Swift. The example code is introduced in this article in detail, which has certain reference learning value for everyone's study or work. If you need it, please follow the editor to learn together.2017-10-10