0

I'm getting this error in latest version of xcode using swift 2

on line

let s = linkTxt.text

Text in linkTxt appears by button "pasteFromClipBoard"

let s = linkTxt.text
        let u = NSURL(string: s!)
        let file = u?.lastPathComponent

What is the reason of it and how to fix it?

Update:

the problem appears in function saveData() which calls when file downloading is finished. It calls from NSURLSessionDataTask function. More interesting, that in start-downloading-button there are the same lines where filename is generating and there is no such error on it. I fixed these issues by declaring variables, writing text's values into them and use these variables in saveData() except textObject.text; I had to delete lines with NSUserDefaults from saveData() too because I got the same error. Did understand nothing >_<

Update 2:

It's really a bug. I've deleted this line and wrote again - problem fixed

SwiftStudier
  • 2,272
  • 5
  • 21
  • 43
  • 1
    when you look into the backtrace, what else do you see? I'm interested in the frames above the one we see here. they will most likely point to functions for which no source code is availaible, only assembly. And, is the bad instruction actually the `ud2` instruction? What are the last lines in the console, when this happens? From what I see already, I would guess this is either an assertion failure or a weakref-problem. – Michael Sep 29 '15 at 20:40
  • In console I see only "lldb". There is no error description – SwiftStudier Sep 29 '15 at 20:41
  • Well, I need a backtrace then, and a disassembly showing the actual bad instruction. – Michael Sep 29 '15 at 20:43
  • where can I find what are you asking for? – SwiftStudier Sep 30 '15 at 07:26

1 Answers1

0

linkTxt.txt is returning nil and NSURL(string: s!) will try to forcefully unwrap it.

let s = linkTxt.text
if let s = linkTxt.txt {
    let u = NSURL(string: s!)
    let file = u?.lastPathComponent
}
Lukas
  • 3,423
  • 2
  • 14
  • 26
  • I'm starting thinking that it's some xcode bugs maybe http://ipic.su/img/img7/fs/Snimokekrana2015-09-30v10.1443597877.png – SwiftStudier Sep 30 '15 at 07:25