gpt4 book ai didi

ios - JSON 和多个顺序 View Controller

转载 作者:行者123 更新时间:2023-11-29 03:25:52 25 4
gpt4 key购买 nike

亲爱的 Stack Overflow 用户,

我有以下 JSON:

 {
"first": [
{
"type": "headingtext",
"label": "Atrial Fibrillation Guideline"
},
{
"type": "text",
"label": "Onset of Atrial Fibrillation?"
},
{
"type": "button",
"label": "Less than 48 hours",
"destination": "less48hours"
},
{
"type": "button",
"label": "More than 48 hours",
"destination": "more48hours"
}
],
"less48hours": [
{
"type": "headingtext",
"label": "Less than 48 hours"
},
{
"type": "text",
"label": "Patient is Stable or Unstable?"
},
{
"type": "button",
"label": "Unstable Patient",
"destination": "unstableless48hours"
},
{
"type": "button",
"label": "Stable Patient",
"destination": "stable"
}
],
"unstableless48hours": [
{
"type": "headingtext",
"label": "Unstable Patient"
},
{
"type": "button",
"label": "High Stroke Risk",
"destination": "highstrokerisk"
},
{
"type": "button",
"label": "Low Stroke",
"destination": "lowstrokerisk"
}
],
"highstrokerisk": [
{
"type": "headingtext",
"label": "High Stroke Risk"
},
{
"type": "text",
"label": "Management Plan"
},
{
"type": "text",
"label": "Cardioversion under Heparin Cover\n-Keep on monitor for 3 hours\n-Need Long Term Oral Anti-coagulation"
}
],
"lowstrokerisk": [
{
"type": "headingtext",
"label": "High Stroke Risk"
},
{
"type": "text",
"label": "Management Plan"
},
{
"type": "text",
"label": "Cardioversion under Heparin Cover\n-Keep on monitor for 3 hours\n-No Need for Long Term Oral Anti-coagulation"
}
],
"stable": [
{
"type": "headingtext",
"label": "Stable Patient"
},
{
"type": "button",
"label": "Healthy",
"destination": "healthyaf"
},
{
"type": "button",
"label": "Unhealthy",
"destination": "unhealthyaf"
}
],
"unhealthyaf": [
{
"type": "headingtext",
"label": "AF in Stable Patients who are unhealthy"
},
{
"type": "text",
"label": "AIM\n-Rate Control\n-Add Oral Anti-Coagulant or Aspirin if Stroke Risk is more than 2"
},
{
"type": "text",
"label": "What is the patient's lifestyle?"
},
{
"type": "button",
"label": "Inactive",
"destination": "inactive"
},
{
"type": "button",
"label": "Active",
"destination": "active"
}
],
"more48hours": [
{
"type": "headingtext",
"label": "More than 48 hours of onset of AF"
},
{
"type": "button",
"label": "Stable",
"destination": "stable"
},
{
"type": "button",
"label": "Unstable",
"destination": "unstablemore48hours"
}
],
"unstablemore48hours": [
{
"type": "headingtext",
"label": "Unstable Patient"
},
{
"type": "text",
"label": "Immediate Cardioversion with Heparin Cover\n-Oral Anticoagulant could be started afterwards and continued for 4 weeks or lifelong if stroke risk factor is more than 1"
}
],
"Inactive": [
{
"type": "headingtext",
"label": "Inactive Lifestyle"
},
{
"type": "text",
"label": "Digoxin"
}
],
"Active": [
{
"type": "headingtext",
"label": "Active Lifestyle"
},
{
"type": "button",
"label": "No Disease/Hypertension",
"destination": "nodiseaseht"
},
{
"type": "button",
"label": "Congestive Heart Failure",
"destination": "chf"
},
{
"type": "button",
"label": "COPD",
"destination": "copd"
}
],
"nodiseaseht": [
{
"type": "headingtext",
"label": "Treatment Options in No Disease/HT"
},
{
"type": "text",
"label": "Beta-Blocker \n-Diltiazem \n-Verapamil \n-Digoxin"
}
],
"chf": [
{
"type": "headingtext",
"label": "Treatment Options in Congestive Heart Failure"
},
{
"type": "text",
"label": "Beta-Blocker \n-Diltiazem"
}
],
"copd": [
{
"type": "headingtext",
"label": "Treatment Options in COPD"
},
{
"type": "text",
"label": "Diltiazem \n-Verapamil \n-Digoxin \n-Beta-1 Selective Blocker"
}
]
}

我在 StackOverflow 上的以下研究并没有给我带来我希望的启发:

multiple view controllers strategy

passing controller json result to view

我的 friend 设法将其转化为具有顺序 View 和导致不同 View Controller 的不同点击的 Android 应用程序,但是如何可能为 iO 和 Objective-C 得出相同的结果?这些平台似乎要困难得多。

我知道需要解析 JSON 数据这一事实,但在将不同的 JSON 操作转换为顺序 View Controller 时不知何故发现困难。

最佳答案

首先将您的响应字符串转换为 NSData。然后

NSDictionary *json = [NSJSONSerialization JSONObjectWithData:yourData options:kNilOptions error:&jsonError];
NSArray *first = [json objectForKey:@"first"];
for (NSDictionary *dict in first) {
NSString *type = [dict objectForKey:@"type"];
/// and so on
}

关于ios - JSON 和多个顺序 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20469037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com