-
Notifications
You must be signed in to change notification settings - Fork 0
/
Swift-I-Dont-Understand.swift
183 lines (129 loc) · 6.06 KB
/
Swift-I-Dont-Understand.swift
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
var enabled: Bool {
didSet { // what does the whole block do?
if let segmentedControl = self.segmentedControl {
segmentedControl.isEnabled = enabled
}
}
}
/* looks like if let foo = bar {
* do something with or to foo *
}
is necessary doing something to something if it is not nil, that is, i believe, it unwraps
the optional-object Bar (which is an Optional<Bar>, or so).
*/
// -------------------------------------------------------------------------------------------------
class RouteTypeCell: UITableViewCell {
@IBOutlet var segmentedControl: UISegmentedControl! // what is the @IBOutlet? what is the !
weak var delegate: RouteTypeCellDelegate? // what is weak?
var routeType: AMSDataRouteType {
didSet {
if let segmentedControl = self.segmentedControl {
switch self.routeType {
case .fastest:
segmentedControl.selectedSegmentIndex = 0
case .shortest:
segmentedControl.selectedSegmentIndex = 1
case .balanced:
segmentedControl.selectedSegmentIndex = 2
}
}
}
}
var enabled: Bool {
didSet {
if let segmentedControl = self.segmentedControl {
segmentedControl.isEnabled = enabled
}
}
}
required init?(coder aDecoder: NSCoder) { // required: every subclass must implement this initializer ...anything else in question ?
self.routeType = .fastest
self.enabled = true
super.init(coder: aDecoder)
}
// MARK: Actions // ?
@IBAction func segmentedControlDidChange(_ sender: UISegmentedControl) {
var routeType: AMSDataRouteType?
switch sender.selectedSegmentIndex {
case 0:
routeType = .fastest
case 1:
routeType = .shortest
case 2:
routeType = .balanced
default:
routeType = nil
}
if let routeType = routeType {
self.delegate?.routeTypeCell(self, didChangeRouteType: routeType)
}
}
}
// -------------------------------------------------------------------------------------------------
func routeTypeCell(_ indexPath: IndexPath) -> UITableViewCell {
// guard? as?
guard let cell = self.tableView.dequeueReusableCell(withIdentifier: "routeTypeCell") as? RouteTypeCell else {
return UITableViewCell()
}
cell.routeType = self.routeType
cell.delegate = self
return cell
}
// -------------------------------------------------------------------------------------------------
if let route = segment.route, let mapRoute = NMAMapRoute(route),
let boundingBox = route.boundingBox {
self.mapView.add(mapObject: mapRoute)
self.mapView.set(boundingBox: boundingBox,
animation: NMAMapAnimation.bow)
}
// -------------------------------------------------------------------------------------------------
for index in 1...limitRoutes {
let route
= AMSDataRoute(segments: [createRandomSegment(index), createRandomSegment(index)])
route.name = "QA:Route[\(index)]\(route.routeHash() ?? "unknown")"
route.addTag(AMSDataTagBuilder.sharedTag())
routes.append(route)
}
// -------------------------------------------------------------------------------------------------
open func remove(_ clusterLayer: NMAClusterLayer!) -> Bool // open?
//--------------------------------------------------------------------------------------------------
self? // what does this mean ?
weak self // same game
//--------------------------------------------------------------------------------------------------
let _ = fileManager.fileExists(atPath: itemSrcURL.path, isDirectory: &srcIsDirectory) // let _ ??
// -------------------------------------------------------------------------------------------------
open
public
interal
private
open class AMSDataTagBuilder : NSObject { // open ? is there open in another context?
// -------------------------------------------------------------------------------------------------
instance0.trafficSpeed = [ 1 : 1, 2 : 2 ]
// -------------------------------------------------------------------------------------------------
internal class _Attributes: Attributes {
var builtInTypeAttribute: UInt32 { // custom implementation for get / set ?
get {
return smoke_Attributes_builtInTypeAttribute_get(c_instance)
}
set {
return smoke_Attributes_builtInTypeAttribute_set(c_instance, newValue) // set and return ???
}
}
// -------------------------------------------------------------------------------------------------
deinit { // is it like a d'tor?
smoke_Attributes_release(c_instance)
}
// -------------------------------------------------------------------------------------------------
public static func explicitArrayMethod<T>(input: T) -> T where T : Collection, T.Element == Arrays.SyncResult { // == ??
return examples_Arrays_explicitArrayMethod(input)
}
// -------------------------------------------------------------------------------------------------
@IBInspectable
@IBAction
// -------------------------------------------------------------------------------------------------
var isMapLoaded: Bool = false {
willSet { // probably related to didSet.. but.. what ??
self.noMapDataView?.isHidden = newValue
}
}
@objc // indicates functions that use objective c framework