Swift 備忘録 文字から数値(UIPickerViewへのデフォルト値セット) 文字から日付(UIDatePickerへのデフォルト値セット)

    • 文字から数値

http://swift-salaryman.com/stringtoint.php

        var str_val: String = indexField.text
        var idx:Int = 0
        if str_val != "" {
            idx = str_val.toInt()!
        }
        pickerView.selectRow(idx, inComponent: 0, animated: true)
    • 文字から日付型

http://qiita.com/matsuhisa_h/items/7c898c0c2d0c523d4c0a

        var str_date: String = dateField.text
        var date: NSDate = NSDate()
        if str_date != "" {
            var date_formatter: NSDateFormatter = NSDateFormatter()
            date_formatter.locale     = NSLocale(localeIdentifier: "ja")
            date_formatter.dateFormat = "yyyy/MM/dd"
            date = date_formatter.dateFromString(str_date)!
        }
        datePickerView.setDate(date, animated: true)

こう言ったリファレンスが、Xcode上でサクッと見つけられない_| ̄|○
クラス内の関数、プロパティもしかり。
史上最低でわかりにくい\(^o^)/オワタ

最●のリファレンスの内容

func selectRow(_ row: Int,
inComponent component: Int,
animated animated: Bool)

row
A zero-indexed number identifying a row of component.
component
A zero-indexed number identifying a component of the picker view.
animated
YES to animate the selection by spinning the wheel (component) to the new value; if you specify NO, the new selection is shown immediately.

componentっていっくら調べてもわけわけめ(*_*) マイッタ
animated をYES、NOにするとこけるし・・・

下記ページにて、解決しますた。
http://oynop.hatenablog.com/entry/2015/02/28/010143

●ップルって、社外へ仕様公開する言語類は、総じて●●ですわ。
いい加減swiftの仕様固めてくださいな AND せめてわかりやすいリファレンス書いてけれ。