ViewController

//
//  ViewController.swift
//  WOEID
//
//  Created by Park on 11/21/15.
//  Copyright © 2015 Park. All rights reserved.
//

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var aTableView: UITableView!
let importer: WOEIDImporter = WOEIDImporter()
var woeidList: [WOEID]! = nil
var woeid: WOEID! = nil

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.title = “WOEID”
//woeidList = importer.loadDataFromCSV(“WOEIDList”)
importer.loadDataFromXML(“WOEIDList”)
woeidList = importer.woeidList

aTableView.delegate = self
aTableView.dataSource = self
aTableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: “cell”)
let tempList = importer.loadData() // test data
importer.exportDataToCSV(tempList, path: “temp”)
importer.exportDataToPList(tempList, path: “temp”)
importer.exportDataToJSON(tempList, path: “temp”)
importer.exportDataToXML(tempList, path: “temp”)

//importer.loadDataFromJSON(“WOEIDJSON”)
/*let tempList2 :[WOEID] = importer.loadDataFromPList(“WOEIDPropertyList”)
for e in tempList2 {
print(e.description)
}*/
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return woeidList.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{

let cell: UITableViewCell = aTableView.dequeueReusableCellWithIdentifier(“cell”) as UITableViewCell!
let woeid = woeidList[indexPath.row] as WOEID
cell.textLabel?.text = “\(woeid.code) \(woeid.city) \(woeid.country)”
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
print(cell.textLabel?.text)
return cell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
tableView.deselectRowAtIndexPath(indexPath, animated: true)
print(“You selected cell #\(indexPath.row)”)

woeid = woeidList[indexPath.row] as WOEID
self.performSegueWithIdentifier(“ShowSimpleVCSegue”, sender: self)

//let woeid = woeidList[indexPath.row] as WOEID
//let aViewController: SimpleViewController = storyboard?.instantiateViewControllerWithIdentifier(“SimpleViewController”) as! SimpleViewController
//aViewController.woeid = woeid
//navigationController?.pushViewController(aViewController, animated: true)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if (segue.identifier == “ShowSimpleVCSegue”) {
if let destinationVC = segue.destinationViewController as? SimpleViewController {
print(“SimpleTableViewController”)
destinationVC.woeid = woeid
}
}
}
}

Term Project

12/7  아이폰/아이패드에 넣어오기

Myrone – 현재 화면구성 했음. 마이론으로 부터 근전도 센서값을 받아서 보여주고 세기값을 저장하고 볼 수 있는 기능 구현.

음주측정기(가제) – UI 구성하고, 혈중 알콜 농도 계산기, 달력구현.

WaterSeven – 레이아웃 전체적으로 완성, 물마시는 화면 구현 50%, 프로필과 연동하여 계산하기

StopSmoking – 기본 메인 UI 작성 및 생체신호 파일(4~5) 작성 및 리딩까지

 

 

MapView

import MapKit

var woeid: WOEID! // data (woeid, city, country, latitude, longitude)

@IBOutlet weak var aMapView: MKMapView!

override func viewDidLoad() {

super.viewDidLoad()

let center = CLLocationCoordinate2D(latitude: woeid.latitude, longitude: woeid.longitude)

let span = MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1)

let region = MKCoordinateRegion(center: center, span: span)

self.aMapView.setRegion(region, animated: true)

 

let annotation = MKPointAnnotation()

annotation.coordinate = center

annotation.title = woeid.city

annotation.subtitle = woeid.country

}

pushViewController

 

// SimpleVC ViewController.swift

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
//let site = sites[indexPath.row] as LectureSite
//selectedURL = site.url
//self.performSegueWithIdentifier(“ShowSimpleVCSegue”, sender: self)

tableView.deselectRowAtIndexPath(indexPath, animated: true)
print(“You selected cell #\(indexPath.row)”)

let site = sites[indexPath.row] as LectureSite
let aViewController: SimpleViewController = storyboard?.instantiateViewControllerWithIdentifier(“SimpleViewController”) as! SimpleViewController
aViewController.name = site.name
aViewController.imageName = site.imageName
aViewController.url = site.url
navigationController?.pushViewController(aViewController, animated: true)
}

 

// SimpleVC SimpleViewController,swift

@IBAction func buttonPressed(sender: AnyObject) {
if let button = sender as? UIButton {
if button == aButton {
self.performSegueWithIdentifier(“ShowDetailVCSegue”, sender: self)
}
else if button == bButton {
self.performSegueWithIdentifier(“ShowOtherDetailVCSegue”, sender: self)
}
}
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if (segue.identifier == “ShowDetailVCSegue”) {
if let destinationVC = segue.destinationViewController as? DetailViewController {
destinationVC.name = name
destinationVC.imageName = imageName
}
}
else if (segue.identifier == “ShowOtherDetailVCSegue”) {
if let destinationVC = segue.destinationViewController as? OtherDetailViewController {
destinationVC.name = name
destinationVC.url = url
}
}
}