{ "pages": 1, "posts": [ { "id": 2345, "categories": [], "tags": [], "author": { "id": 1, "slug": "admin", "url": "", "description": "" }, "comments": [], "custom_fields": { "slide_template": [ "default" ], "request_status": [ "Pending Review" ], "branch": [ "Branch B" ], "assigned_to": [ "Managing Director" ], "category": [ "Equipment" ], "priority": [ "High" ] } },
this is my swift coding till "custom_fields" i can able to fetch the value but after that i cant able to please anyone help me
let url = NSURL(string: urlForCharts)
do{
URLSession.shared.dataTask(with: (url as URL?)!, completionHandler: {(data, response, error) -> Void in
if let data = data {
if let jsonObj = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? NSDictionary {
if let postArray = jsonObj!.value(forKey: "posts") as? NSArray {
for status in postArray{
if let tagsDict = status as? NSDictionary {
if let tagsArray = tagsDict.value(forKey: "custom_fields") as? NSArray {
for statusArray in tagsArray{
if let statusDict = statusArray as? NSDictionary {
if let status = statusDict.value(forKey: "request_status") {
self.ticketStatus.append((status as? String)!)
self.ticketStatus = self.ticketStatus.sorted(by: <)