线程1:断点4.1 - Swift

时间:2015-01-20 11:26:32

标签: ios swift xcode6

每当我使用" println(buildDateString(" xx"," xx"," xx"," xx&)调用我的buildDateString方法时#34;," xx")"我的应用程序崩溃,给我错误"线程1:断点4.1"

import Foundation
import UIKit

func getDateFromString(dateString: String) -> NSDate? {
    var dateFormatter: NSDateFormatter = NSDateFormatter()

    dateFormatter.dateFormat = "MM-dd-yyyy-kk-mm-ss"
    dateFormatter.timeZone = NSTimeZone.localTimeZone()

    return dateFormatter.dateFromString(dateString)
}

func getCurrentDateAsArray() -> [Int] {
    var dateFormatter: NSDateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "MM-dd-yyyy-kk-mm-ss"
    dateFormatter.timeZone = NSTimeZone.localTimeZone()

    var dateString = dateFormatter.stringFromDate(NSDate())

    return stringToIntArray(dateString.componentsSeparatedByString("-"))
}

func stringToIntArray(stringArray: [String]) -> [Int] {
    var intArray: [Int] = []

    for element in stringArray {
        intArray.append(element.toInt()!)
    }

    return intArray
}

func intToStringArray(intArray: [Int]) -> [String] {
    var stringArray: [String] = []

    for element in intArray {
        stringArray.append("\(element)")
    }

    return stringArray
}

func buildDateString(day: String, month: String, hour: String, minute: String, second: String) -> String {
    var dayValue = day
    var monthValue = month
    var hourValue = hour
    var minuteValue = minute
    var secondValue = second
    var currentDate = getCurrentDateAsArray()

    println(currentDate)

    dayValue = dayValue.utf16Count == 1 ? "0" + dayValue : dayValue
    monthValue = monthValue.utf16Count == 1 ? "0" + monthValue : monthValue
    hourValue = hourValue.utf16Count == 1 ? "0" + hourValue : hourValue
    minuteValue = minuteValue.utf16Count == 1 ? "0" + minuteValue : minuteValue
    secondValue = secondValue.utf16Count == 1 ? "0" + secondValue : secondValue

    var bool1 = monthValue.toInt() > currentDate[0]
    var bool2 = monthValue.toInt() == currentDate[0] && dayValue.toInt() > currentDate[1]
    var bool3 = monthValue.toInt() == currentDate[0] && dayValue.toInt() == currentDate[1] && hourValue.toInt() > currentDate[3]
    var bool4 = monthValue.toInt() == currentDate[0] && dayValue.toInt() == currentDate[1] && hourValue.toInt() == currentDate[3] && minuteValue.toInt() > currentDate[4]
    var bool5 = monthValue.toInt() == currentDate[0] && dayValue.toInt() == currentDate[1] && hourValue.toInt() == currentDate[3] && minuteValue.toInt() == currentDate[4] && secondValue.toInt() > currentDate[5]

    if (bool1 || bool2 || bool3 || bool4 || bool5) {
        currentDate[2] = currentDate[2] + 1
    }

    var currentDateStringArray: [String] = [monthValue, dayValue, "\(currentDate[2])", hourValue,minuteValue, secondValue]

    return "-".join(currentDateStringArray)
}

我不明白为什么会发生这种情况,xCode也没有给出任何关于错误可能的提示。

我正在使用iOS 8.2 SDK和xCode 6.2 beta 4

错误被抛到这一行:

println(buildDateString("12", "5", "12", "12", "7"))

1 个答案:

答案 0 :(得分:1)

这意味着你设置了断点,我相信它就行了:

println(buildDateString("xx","xx","xx","xx","xx")

只需删除/禁用断点,就可以了。

要停用断点,您可以从xCode菜单中选择Debug和Deactivate breakpoints,或使用apple key + Y快捷键。