0

I have got this piece of code :

     var array: [Int]? = []

 array = data.characters.split(){$0 == ","}.map{
        (Int(String.init($0).
stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())))!}

which reads the data from the file and if there are Ints separated by a single comma, it will convert them into array of Int. My question is how do I safely wrap it so I dont get this error : fatal error: unexpectedly found nil while unwrapping an Optional value ?

user3395936
  • 651
  • 3
  • 13
  • 26

0 Answers0