ios - 使用 componentsSeparatedByString() 断点

标签 ios iphone xcode swift breakpoints

我正在为一个应用程序使用 MapKit

我正在将信息存储在全局字典中,然后再次访问它们。

每个都使用文本+用户名+日期的键存储。此实例中的用户名变量包含字符串的日期和用户名

func mapView (mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView{
    var pinView = MKPinAnnotationView()
    var imageView: UIImageView = UIImageView()
    var button: UIButton = UIButton()
    let username = annotation.title!.componentsSeparatedByString(" - ")
    var string: String = annotation.subtitle! + username[0] + username[1] as String!
    println(string)
    println(PPs[string])
    var pp = PPs[string]

username = annotation.title 行上,它在该行的断点处停止(我已将其关闭)。

 EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)

我想知道当我声明用户名时出了什么问题,我已经尝试过 let 和 var。

最佳答案

这很可能意味着 annotationannotation.title 为 nil。我建议在函数体的第一行打断点并检查 annotation 参数。

关于ios - 使用 componentsSeparatedByString() 断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26672711/

相关文章:

iphone - iOS环境下的可靠时差

xcode - 是否有键盘快捷键可以清除 XCode 左侧导航器中的过滤器?

ios - Xcode 的 ":configuration"条件编译指令如何在 xcconfig 文件中工作?

iphone - 有没有办法自定义 iPhone 上现有的联系人应用程序?

ios - React Native archive error : Unable to find React Native files. 确保在项目依赖项中安装了 "react-native"模块

iphone - 用于 iPhone 编程的 CFDataRef 和像素数据

iphone - Google map 着色 - iOS

iphone - 如何在应用商店发布应用更新?

iPhone - facebook 登录后,UISwitch 的状态未在 -(void)fbDidLogin 方法中设置为 'On'

iphone - 在 UITableView 的 iOS 文档目录中列出保存的文件?