Skip to content

Commit

Permalink
Merge pull request #3 from amarofashion/insert-method-convert-questio…
Browse files Browse the repository at this point in the history
…ns-to-questionsFormatter

Create method to convert [question] in [questionsFormatter]
  • Loading branch information
lilianeblima authored Dec 7, 2017
2 parents ca9e7c4 + 910063a commit 78a7cee
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions yotpoKit/ProductQuestion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,20 @@ public struct ProductQuestion {
return myQuestions
}
}

public extension Sequence where Iterator.Element == Question {
public func convertQuestionToQuestionFormatter() -> [QuestionExhibition] {
var myQuestionFormatter: [QuestionExhibition] = []

for selectQuestion in self {
let questExhibition = QuestionExhibition(withQuestion: selectQuestion)
myQuestionFormatter.append(questExhibition)

for answer in selectQuestion.answers {
let answerExhibition = QuestionExhibition(withAnswer: answer, idQuest: selectQuestion.id)
myQuestionFormatter.append(answerExhibition)
}
}
return myQuestionFormatter
}
}

0 comments on commit 78a7cee

Please sign in to comment.