質問編集履歴

1

コードを見やすく修正しました。

2015/10/03 02:09

投稿

c8h14
c8h14

スコア12

test CHANGED
File without changes
test CHANGED
@@ -204,78 +204,54 @@
204
204
 
205
205
  func settingFareTableView(){
206
206
 
207
-
208
-
209
- print("settingFareTableView")
210
-
211
-
212
-
213
207
  fareTableView = UITableView(frame: CGRectMake(0, 512, 320, CGFloat(60 * fares.count)))
214
208
 
215
209
 
216
210
 
211
+ // Cell名の登録をおこなう.
212
+
213
+ fareTableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: "FareCell")
214
+
215
+ // DataSourceの設定をする.
216
+
217
+ fareTableView!.dataSource = self
218
+
219
+ // Delegateを設定する.
220
+
221
+ fareTableView!.delegate = self
222
+
223
+ // Viewに追加する.
224
+
225
+ scrollView.addSubview(fareTableView!)
226
+
227
+
228
+
229
+ fareTableView?.tag = 1
230
+
231
+ }
232
+
233
+
234
+
235
+ func settingOptionTableView(){
236
+
237
+
238
+
239
+ optionTableView = UITableView(frame: CGRectMake(0, optionHight + 44, 320, CGFloat(60 * options.count)))
240
+
217
241
  // Cell名の登録をおこなう.
218
242
 
219
- fareTableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: "FareCell")
243
+ optionTableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: "OptionCell")
220
-
221
-
222
244
 
223
245
  // DataSourceの設定をする.
224
246
 
225
- fareTableView!.dataSource = self
247
+ optionTableView!.dataSource = self
226
-
227
-
228
248
 
229
249
  // Delegateを設定する.
230
250
 
231
- fareTableView!.delegate = self
251
+ optionTableView!.delegate = self
232
-
233
-
234
252
 
235
253
  // Viewに追加する.
236
254
 
237
- scrollView.addSubview(fareTableView!)
238
-
239
-
240
-
241
- fareTableView?.tag = 1
242
-
243
- }
244
-
245
-
246
-
247
- func settingOptionTableView(){
248
-
249
-
250
-
251
- print("settingOptionTableView")
252
-
253
-
254
-
255
- optionTableView = UITableView(frame: CGRectMake(0, optionHight + 44, 320, CGFloat(60 * options.count)))
256
-
257
-
258
-
259
- // Cell名の登録をおこなう.
260
-
261
- optionTableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: "OptionCell")
262
-
263
-
264
-
265
- // DataSourceの設定をする.
266
-
267
- optionTableView!.dataSource = self
268
-
269
-
270
-
271
- // Delegateを設定する.
272
-
273
- optionTableView!.delegate = self
274
-
275
-
276
-
277
- // Viewに追加する.
278
-
279
255
  scrollView.addSubview(optionTableView!)
280
256
 
281
257
 
@@ -294,28 +270,14 @@
294
270
 
295
271
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
296
272
 
297
-
298
-
299
- print("numberOfRowsInSection:\(options)")
300
-
301
-
302
-
303
- var cellCount = 0
273
+ var cellCount = 0
304
-
305
-
306
274
 
307
275
  if tableView.tag == 1{
308
276
 
309
-
310
-
311
277
  cellCount = fares.count
312
278
 
313
-
314
-
315
279
  }else if tableView.tag == 2{
316
280
 
317
-
318
-
319
281
  cellCount = options.count
320
282
 
321
283
  }
@@ -344,18 +306,10 @@
344
306
 
345
307
 
346
308
 
347
- print("cellForRowAtIndexPath\(indexPath.row)")
348
-
349
-
350
-
351
309
  // 再利用するCellを取得する.
352
310
 
353
311
  // let cell = tableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath:indexPath)
354
312
 
355
-
356
-
357
-
358
-
359
313
  var cell:UITableViewCell = UITableViewCell()
360
314
 
361
315
 
@@ -366,12 +320,8 @@
366
320
 
367
321
  cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "FareCell")
368
322
 
369
-
370
-
371
323
  let fare:[String] = fares[indexPath.row]
372
324
 
373
-
374
-
375
325
  cell.textLabel?.text = fare[0]
376
326
 
377
327
  cell.detailTextLabel?.text = fare[1]
@@ -384,16 +334,6 @@
384
334
 
385
335
  cell = UITableViewCell(style: UITableViewCellStyle.Value2, reuseIdentifier: "OptionCell")
386
336
 
387
-
388
-
389
- // Cellに値を設定する.
390
-
391
- // let option:[String] = driverAndCar.options[indexPath.row]
392
-
393
-
394
-
395
-
396
-
397
337
  let option:[String] = options[indexPath.row]
398
338
 
399
339
 
@@ -442,12 +382,6 @@
442
382
 
443
383
  func getFareDatas(companyObject:PFObject!){
444
384
 
445
-
446
-
447
- print("getFareDatas:\(companyObject)")
448
-
449
-
450
-
451
385
  let query = PFQuery(className: "Fare")
452
386
 
453
387
  query.whereKey("company", equalTo: companyObject)
@@ -494,104 +428,66 @@
494
428
 
495
429
 
496
430
 
431
+ let fare:[String] = [title,fareDetail]
432
+
433
+ self.fares.append(fare)
434
+
435
+ }
436
+
437
+ }
438
+
439
+ self.getOptionDatas(companyObject) ・・・ ※2
440
+
441
+ }
442
+
443
+ }
444
+
445
+
446
+
447
+
448
+
449
+ func getOptionDatas(companyObject:PFObject!){
450
+
451
+ let query = PFQuery(className: "Option")
452
+
453
+ query.whereKey("company", equalTo: companyObject)
454
+
455
+ query.orderByAscending("order")
456
+
457
+
458
+
459
+ query.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) -> Void in
460
+
461
+
462
+
463
+ if error == nil {
464
+
465
+
466
+
467
+ for object in objects! {
468
+
497
469
 
498
470
 
499
- let fare:[String] = [title,fareDetail]
471
+ let item = object["item"] as! String
472
+
473
+ let fare = String(object["fare"] as! Int) + "円"
500
474
 
501
475
 
502
476
 
503
- self.fares.append(fare)
477
+ let option:[String] = [item,fare]
504
-
505
-
506
478
 
507
479
 
508
480
 
481
+ self.options.append(option)
482
+
483
+
484
+
509
- }
485
+ }
510
-
511
-
512
486
 
513
487
  }
514
488
 
515
-
516
-
517
- self.getOptionDatas(companyObject) ・・・ ※2
518
-
519
-
520
-
521
- }
489
+ }
522
-
523
-
524
-
490
+
525
- }
491
+ }
526
-
527
-
528
-
529
-
530
-
531
- func getOptionDatas(companyObject:PFObject!){
532
-
533
-
534
-
535
- print("getOptionDatas:\(companyObject)")
536
-
537
-
538
-
539
- let query = PFQuery(className: "Option")
540
-
541
- query.whereKey("company", equalTo: companyObject)
542
-
543
- query.orderByAscending("order")
544
-
545
-
546
-
547
- query.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) -> Void in
548
-
549
-
550
-
551
- if error == nil {
552
-
553
-
554
-
555
- for object in objects! {
556
-
557
-
558
-
559
- let item = object["item"] as! String
560
-
561
- let fare = String(object["fare"] as! Int) + "円"
562
-
563
-
564
-
565
- let option:[String] = [item,fare]
566
-
567
-
568
-
569
- self.options.append(option)
570
-
571
-
572
-
573
-
574
-
575
- }
576
-
577
-
578
-
579
- }
580
-
581
-
582
-
583
-
584
-
585
- }
586
-
587
-
588
-
589
- }
590
-
591
-
592
-
593
-
594
-
595
-
596
492
 
597
493
  }