-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiteratingOverArray.swift
More file actions
35 lines (26 loc) · 1.07 KB
/
iteratingOverArray.swift
File metadata and controls
35 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class Person {
var name : String?
var city : String?
var phone : String?
init(iname : String, icity: String, iphone: String){
name = iname
city = icity
phone = iphone
}
}
var personArray = [Person]()
personArray.append(Person(iname: "Bryan", icity: "Glasgow", iphone: "01412222222"))
personArray.append(Person(iname: "Brian", icity: "London", iphone: "01412222456"))
personArray.append(Person(iname: "Jon", icity: "Edinburgh", iphone: "01412222356"))
personArray.append(Person(iname: "Chris", icity: "Glasgow", iphone: "01412222234"))
personArray.append(Person(iname: "Kris", icity: "Paris", iphone: "01412222876"))
personArray.append(Person(iname: "George", icity: "Glasgow", iphone: "01412224456"))
personArray.append(Person(iname: "Betty", icity: "Glasgow", iphone: "01412222667"))
personArray.append(Person(iname: "Wendy", icity: "Perth", iphone: "01412222224"))
print(personArray.count)
print(personArray[0].name!)
for items in personArray {
if items.city == "Glasgow"{
print("\(items.name!) lives in \(items.city!)")
}
}