ios - 线程 1 : Breakpoint 4. 1 - swift

标签 ios swift xcode6

<分区>

每当我使用“println(buildDateString("xx","xx","xx","xx","xx")"调用我的 buildDateString 方法时,我的应用程序崩溃,给我错误消息“线程 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 也没有给我任何关于错误可能是什么的提示。

我正在使用带有 xCode 6.2 beta 4 的 iOS 8.2 SDK

错误被抛到这一行:

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

最佳答案

说明你设置了断点,我相信就行了:

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

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

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

关于ios - 线程 1 : Breakpoint 4. 1 - swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28044211/

相关文章:

iphone - Facebook API BUG?

ios - 调整图像大小而不扭曲或裁剪它

memory-leaks - Instruments 堆栈跟踪中缺少方法调用

ios - 将 iOS6.1 模拟器添加到 Xcode 6

ios - Apollo iOS 将 JSONArray 转换为 String

iOS swift 如何将 imageview 准确地放置在 uiview 中

ios - 在ios tableview中,为什么section是NSIndexSet?

iOS Firebase Cloud Messaging 在应用程序关闭时获取数据

Swift 3 替换多个字符串的出现

iOS模拟器不播放声音