Advertisement
Guest User

Untitled

a guest
Feb 15th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController {
  4. @IBOutlet var testlabel: UILabel!
  5.  
  6. let aaa = 10//การประกาศตัวแปลแบบโกลบอล
  7.  
  8.  
  9. override func viewDidLoad() {
  10. super.viewDidLoad()
  11. // Do any additional setup after loading the view.
  12. testlabel.text = "assq"
  13. print("Hello World" )
  14. print(aaa)//การเรียกใช้ตัวแปลแบบโกลบอล
  15. print(self.aaa) //การเรียกใช้ตัวแปลแบบโกลบอลทั้งหมด
  16.  
  17. let x:String = "Hello" //ตัวแปลเปลี่ยนค่าไม่ได้ //สามารถกำหนด type ได้
  18. var y:Int = 12 //ตัวแปลเปลี่ยนค่าได้
  19.  
  20. //x = "Arer"
  21. //y = "fill"
  22. print("\(x)\(y)") //เป็นเครื่องหมาย\เปลี่ยนตัวแปรให้เป็นstring
  23. let arr1 = [10,11,12] //การประกาศAray
  24. let arr2:[Int] = [1,2,3]
  25. print(arr1)
  26. print(arr1[0])
  27. print(arr1[1])
  28. print(arr1[2])
  29. print(arr2)
  30.  
  31. let dict = ["a":1,"b":2,"c":3] //dichinaly
  32. let dict2:[String:Int] = import UIKit
  33.  
  34. class ViewController: UIViewController {
  35. @IBOutlet var testlabel: UILabel!
  36.  
  37. let aaa = 10//การประกาศตัวแปลแบบโกลบอล
  38.  
  39.  
  40. override func viewDidLoad() {
  41. super.viewDidLoad()
  42. // Do any additional setup after loading the view.
  43. testlabel.text = "assq"
  44. print("Hello World" )
  45. print(aaa)//การเรียกใช้ตัวแปลแบบโกลบอล
  46. print(self.aaa) //การเรียกใช้ตัวแปลแบบโกลบอลทั้งหมด
  47.  
  48. let x:String = "Hello" //ตัวแปลเปลี่ยนค่าไม่ได้ //สามารถกำหนด type ได้
  49. var y:Int = 12 //ตัวแปลเปลี่ยนค่าได้
  50.  
  51. //x = "Arer"
  52. //y = "fill"
  53. print("\(x)\(y)") //เป็นเครื่องหมาย\เปลี่ยนตัวแปรให้เป็นstring
  54. let arr1 = [10,11,12] //การประกาศAray
  55. let arr2:[Int] = [1,2,3]
  56. print(arr1)
  57. print(arr1[0])
  58. print(arr1[1])
  59. print(arr1[2])
  60. print(arr2)
  61.  
  62. let dict = ["a":1,"b":2,"c":3] //dichinaly
  63. let dict2:[String:Int] = ["a":1,"b":2,"c":3]
  64. print(dict)
  65. print(dict2)
  66.  
  67. arr1.forEach{value in print(value)}
  68.  
  69. for i in 0..<10{
  70. print(i)} //การวนลูปfor
  71.  
  72. // Int(); a = 10 //การทำif-else
  73. // Int b = 9
  74.  
  75. // if a == 10 && b == 9{
  76. // print("10")
  77. //}
  78.  
  79. struct Student{
  80. var id:String
  81. var name:String
  82. var lastname:String
  83. var age:Int
  84. } //การทำสตัก
  85. var student1: Student = Student(id:
  86. "0001",name: "arawdy",
  87. lastname:"tc",age:20)//การกำหนดค่าให้สตัก
  88. print(student1)
  89. print(student1.name)
  90.  
  91. student1.name = "4DaccZ" //การเปลี่ยนค่าในสตักที่กำหนด
  92. print(student1)
  93. print(student1.name)
  94.  
  95.  
  96.  
  97.  
  98. }
  99.  
  100.  
  101. }
  102. ["a":1,"b":2,"c":3]
  103. print(dict)
  104. print(dict2)
  105.  
  106. arr1.forEach{value in print(value)}
  107.  
  108. for i in 0..<10{
  109. print(i)} //การวนลูปfor
  110.  
  111. // Int(); a = 10 //การทำif-else
  112. // Int b = 9
  113.  
  114. // if a == 10 && b == 9{
  115. // print("10")
  116. //}
  117.  
  118. struct Student{
  119. var id:String
  120. var name:String
  121. var lastname:String
  122. var age:Int
  123. } //การทำสตัก
  124. var student1: Student = Student(id:
  125. "0001",name: "arawdy",
  126. lastname:"tc",age:20)//การกำหนดค่าให้สตัก
  127. print(student1)
  128. print(student1.name)
  129.  
  130. student1.name = "4DaccZ" //การเปลี่ยนค่าในสตักที่กำหนด
  131. print(student1)
  132. print(student1.name)
  133.  
  134.  
  135.  
  136.  
  137. }
  138.  
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement