ios - Swift owned to guaranteed -


i found 5 crash reports inside xcode organizer. when open them stacktrace (marked area name of app):

enter image description here

this error occurs on ios8.4 on ios9, , on iphone 5 , iphone 6 devices likewise.

it hard me track down because cannot reproduce neither on iphone5(8.4) nor on iphone6(9.0.1).

1./2. somewhere here:

override func onbuttontableviewcellclick(button: bfpaperbutton) {} 

3.

var button: bfpaperbutton = bfpaperbutton.newautolayoutview()  func onclick() {     delegate?.onbuttontableviewcellclick(button) // 3 } 

i use swift 2, xcode 7 , ios9. me understand error. first line red image mean? why has error swift.string @ all??

i found thread: https://forums.developer.apple.com/thread/6078 extracted information:

one case i've seen of kind of crash when obj-c-based object calls delegate method that's swift-based, , parameter value nil swift method signature isn't optional type. in case saw, error in bridged delegate method signature — supposed optional. similar in case (the swift definition doesn't allow optional when should), or bug in obj-c code (producing nil when shouldn't).

i use obj-c lib called bfpaperbutton creates button looks in android material design. maybe error related library?

log:

enter image description here

view image: http://i.stack.imgur.com/5aq8m.png

i have 2 string extensions. 1 length , 1 substring:

extension string {      var length: int { return self.characters.count }      subscript (i: int) -> string {         return string(array(self.characters)[i])     }      subscript (r: range<int>) -> string {         let start = startindex.advancedby(r.startindex)         let end = startindex.advancedby(r.endindex)         return substringwithrange(range(start: start, end: end))     } } 

line 188 is:

nsuuid().uuidstring[0...4] 

which uses substring extension. maybe error here?

override func onbuttontableviewcellclick(button: uibutton) {          if let title = button.titlelabel?.text {              if title == "send code" {                  tmpphonenumber = ""                  var tmp = phonenumber                  if tmp.length > 1 {                     if tmp[0] == "0" {                         tmp = tmp[1...tmp.characters.count - 1]                     }                      tmpphonenumber = "0049" + tmp                     phonenumberwithcode = tmpphonenumber                     sendalert(tmp)                 } else {                     pftoast.showerror("please enter phone number.")                 }              } else if title == "finish" {                 if let cell: inputtableviewcell = tableview.cellforrowatindexpath(nsindexpath(forrow: 0, insection: 2)) as? inputtableviewcell {                     if islicencevalid(cell.inputfield.inputfield.text!) {                         createcustomer(cell.inputfield.inputfield.text!)                     } else {                         pftoast.showerror("please enter correct licence plate.")                     }                 }             }         }     } 

in opinion, looking @ wrong places. when looking @ logs, see is:

  1. a click on button
  2. onbuttontableviewcellclick
  3. obj-c swift internals (you can learn more in what's dead & exploded in swift's exception stack?)
  4. indexing string int (see string.subscript.getter (swift.int) -> string)

we can sure crash happened somewhere here:

return string(array(self.characters)[i]) 

i think can rule out nil because cause earlier crash. have character index out of bounds problem. means i either negative or higher length - 1 (maybe indexing empty text?)

unfortunately, important code in onbuttontableviewcellclick , haven't posted that.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -