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 Int
s 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
?