@@ -183,109 +183,111 @@ func convert(_ options: Options) -> Int32 {
183
183
}
184
184
185
185
enum DisplayType {
186
- case Primary
187
- case Key
188
- case Value
186
+ case primary
187
+ case key
188
+ case value
189
189
}
190
190
191
191
extension Dictionary {
192
- func display( _ indent: Int = 0 , type: DisplayType = . Primary ) {
192
+ func display( _ indent: Int = 0 , type: DisplayType = . primary ) {
193
193
let indentation = String ( repeating: " " , count: indent * 2 )
194
- if type == . Primary || type == . Key {
194
+ switch type {
195
+ case . primary, . key:
195
196
print ( " \( indentation) [ \n " , terminator: " " )
196
- } else {
197
+ case . value :
197
198
print ( " [ \n " , terminator: " " )
198
199
}
199
-
200
+
200
201
forEach ( ) {
201
202
if let key = $0. 0 as? String {
202
- key. display ( indent + 1 , type: . Key )
203
+ key. display ( indent + 1 , type: . key )
203
204
} else {
204
205
fatalError ( " plists should have strings as keys but got a \( type ( of: $0. 0 ) ) " )
205
206
}
206
207
print ( " => " , terminator: " " )
207
- displayPlist ( $0. 1 , indent: indent + 1 , type: . Value )
208
+ displayPlist ( $0. 1 , indent: indent + 1 , type: . value )
208
209
}
209
210
210
211
print ( " \( indentation) ] \n " , terminator: " " )
211
212
}
212
213
}
213
214
214
215
extension Array {
215
- func display( _ indent: Int = 0 , type: DisplayType = . Primary ) {
216
+ func display( _ indent: Int = 0 , type: DisplayType = . primary ) {
216
217
let indentation = String ( repeating: " " , count: indent * 2 )
217
- if type == . Primary || type == . Key {
218
+ switch type {
219
+ case . primary, . key:
218
220
print ( " \( indentation) [ \n " , terminator: " " )
219
- } else {
221
+ case . value :
220
222
print ( " [ \n " , terminator: " " )
221
223
}
222
-
224
+
223
225
for idx in 0 ..< count {
224
226
print ( " \( indentation) \( idx) => " , terminator: " " )
225
- displayPlist ( self [ idx] , indent: indent + 1 , type: . Value )
227
+ displayPlist ( self [ idx] , indent: indent + 1 , type: . value )
226
228
}
227
229
228
230
print ( " \( indentation) ] \n " , terminator: " " )
229
231
}
230
232
}
231
233
232
234
extension String {
233
- func display( _ indent: Int = 0 , type: DisplayType = . Primary ) {
235
+ func display( _ indent: Int = 0 , type: DisplayType = . primary ) {
234
236
let indentation = String ( repeating: " " , count: indent * 2 )
235
- if type == . Primary {
237
+ switch type {
238
+ case . primary:
236
239
print ( " \( indentation) \" \( self ) \" \n " , terminator: " " )
237
- }
238
- else if type == . Key {
240
+ case . key:
239
241
print ( " \( indentation) \" \( self ) \" " , terminator: " " )
240
- } else {
242
+ case . value :
241
243
print ( " \" \( self ) \" \n " , terminator: " " )
242
244
}
243
245
}
244
246
}
245
247
246
248
extension Bool {
247
- func display( _ indent: Int = 0 , type: DisplayType = . Primary ) {
249
+ func display( _ indent: Int = 0 , type: DisplayType = . primary ) {
248
250
let indentation = String ( repeating: " " , count: indent * 2 )
249
- if type == . Primary {
251
+ switch type {
252
+ case . primary:
250
253
print ( " \( indentation) \" \( self ? " 1 " : " 0 " ) \" \n " , terminator: " " )
251
- }
252
- else if type == . Key {
254
+ case . key:
253
255
print ( " \( indentation) \" \( self ? " 1 " : " 0 " ) \" " , terminator: " " )
254
- } else {
256
+ case . value :
255
257
print ( " \" \( self ? " 1 " : " 0 " ) \" \n " , terminator: " " )
256
258
}
257
259
}
258
260
}
259
261
260
262
extension NSNumber {
261
- func display( _ indent: Int = 0 , type: DisplayType = . Primary ) {
263
+ func display( _ indent: Int = 0 , type: DisplayType = . primary ) {
262
264
let indentation = String ( repeating: " " , count: indent * 2 )
263
- if type == . Primary {
265
+ switch type {
266
+ case . primary:
264
267
print ( " \( indentation) \" \( self ) \" \n " , terminator: " " )
265
- }
266
- else if type == . Key {
268
+ case . key:
267
269
print ( " \( indentation) \" \( self ) \" " , terminator: " " )
268
- } else {
270
+ case . value :
269
271
print ( " \" \( self ) \" \n " , terminator: " " )
270
272
}
271
273
}
272
274
}
273
275
274
276
extension NSData {
275
- func display( _ indent: Int = 0 , type: DisplayType = . Primary ) {
277
+ func display( _ indent: Int = 0 , type: DisplayType = . primary ) {
276
278
let indentation = String ( repeating: " " , count: indent * 2 )
277
- if type == . Primary {
279
+ switch type {
280
+ case . primary:
278
281
print ( " \( indentation) \" \( self ) \" \n " , terminator: " " )
279
- }
280
- else if type == . Key {
282
+ case . key:
281
283
print ( " \( indentation) \" \( self ) \" " , terminator: " " )
282
- } else {
284
+ case . value :
283
285
print ( " \" \( self ) \" \n " , terminator: " " )
284
286
}
285
287
}
286
288
}
287
289
288
- func displayPlist( _ plist: Any , indent: Int = 0 , type: DisplayType = . Primary ) {
290
+ func displayPlist( _ plist: Any , indent: Int = 0 , type: DisplayType = . primary ) {
289
291
if let val = plist as? Dictionary < String , Any > {
290
292
val. display ( indent, type: type)
291
293
} else if let val = plist as? Array < Any > {
0 commit comments