There are syntax error in it. New to Swift :(
var inputString: String = "Hello its question? </question> Oky its the answer"
let splitter: String = "</question>"
var splittedArray = [inputString .componentsSeparatedByString(splitter)]
var questionIndex = 0
var answerIndex = 0
var mQuestions = []
var mAnswers = []
for var index = 0; index < splittedArray.count; ++index {
if index % 2 == 0{
// Question comes first
splittedArray.append(mQuestions[questionIndex])
questionIndex++
}else{
// Answer comes second
splittedArray.append(mAnswers[answerIndex])
answerIndex++
}
}
Error is:
An Object is not convertable to String,
at this line of code.
splittedArray.append(mQuestions[questionIndex])