Я занимаюсь разработкой приложения для Mac OS. Я должен связать некоторые конкретные поля массива объектов JSON с NSOutlineView
в пользовательском интерфейсе.
func LoadQuestionPaper(){
do{
let jsonResult = try JSONSerialization.jsonObject(with: ExamQuestion!) //Examquestion is data
DispatchQueue.main.async {
self.QuestionOutlineView.value(forKey: jsonResult) //Binding to NSOutlineView
}
}catch {
print(error)
}
}
Вот данные json:
[ {
"id": 1,
"type": "sub",
"text": "{\\rtf1\\ansi\\ansicpg1252\\uc1\\htmautsp\\deff2{\\fonttbl{\\f0\\fcharset0 Times New Roman;}{\\f2\\fcharset0 Segoe UI;}}{\\colortbl\\red0\\green0\\blue0;\\red255\\green255\\blue255;}\\loch\\hich\\dbch\\pard\\plain\\ltrpar\\itap0{\\lang1033\\fs18\\f2\\cf0 \\cf0\\ql{\\fs24\\f0\\b {\\lang2057\\ltrch Short notes: Concept based (20 marks)}\\li0\\ri0\\sa0\\sb0\\fi0\\qj\\par}\r\n{\\fs24\\f0\\b {\\ltrch }\\li0\\ri0\\sa0\\sb0\\fi0\\qj\\par}\r\n{\\f2 {\\ltrch }\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}\r\n}\r\n}",
"num_toans": 4,
"total_marks": 20,
"questions": [
{
"IsAnswered": null,
"markedForReview": null,
"id": 1,
"marks": 5,
"type": "etq",
"q_text": "{\\rtf1\\ansi\\ansicpg1252\\uc1\\htmautsp\\deff2{\\fonttbl{\\f0\\fcharset0 Times New Roman;}{\\f2\\fcharset0 Segoe UI;}}{\\colortbl\\red0\\green0\\blue0;\\red255\\green255\\blue255;}\\loch\\hich\\dbch\\pard\\plain\\ltrpar\\itap0{\\lang1033\\fs18\\f2\\cf0 \\cf0\\ql{\\fs24\\f0 {\\lang2057\\ltrch Why will ABC unit cost figures be different from TCA unit cost figures}{\\lang2057\\ltrch \\rdblquote }{\\lang2057\\ltrch ?}\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}\r\n}\r\n}",
"attachments": null,
"choices": null,
"tfq_ans": null,
"blank_count": 0,
"fitb_ans": null,
"mcq_index": -1,
"mcq_text": null,
"excel_ans_attachment": "0",
"word_ans_attachment": "0",
"essay_ans_attachment": null,
"subSections": null
},
Я не знаю, как связать объект json с NSOutlineView
. Может кто-нибудь предложить мне, как связать его с NSOutlineView
.