程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios-IOS swift 字符串解析成NSArry類型

ios-IOS swift 字符串解析成NSArry類型

編輯:編程綜合問答
IOS swift 字符串解析成NSArry類型

[{"Android":[{"ID":31,"TN":"天天","Date":"2015-03-17","Des":"315活動"},{"ID":32,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":33,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":34,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":35,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":36,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":38,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":22,"TN":"天天","Date":"2015-01-31","Des":"sdaSDASD"},{"ID":23,"TN":"天天","Date":"2015-01-31","Des":"fgsdfgsdfg"},{"ID":7,"TN":"天天","Date":"2015-01-17","Des":"課外活動"},{"ID":8,"TN":"天天","Date":"2015-01-17","Des":"sun sun"},{"ID":9,"TN":"天天","Date":"2015-01-17","Des":"美不勝收,應接不暇"},{"ID":11,"TN":"天天","Date":"2015-01-17","Des":"fgsdjfgsdgfb"},{"ID":12,"TN":"天天","Date":"2015-01-17","Des":"frvxfsdds"},{"ID":13,"TN":"天天","Date":"2015-01-17","Des":"hahahahahhh"},{"ID":14,"TN":"天天","Date":"2015-01-17","Des":"盛開的菊花"},{"ID":15,"TN":"天天","Date":"2015-01-17","Des":"燈塔"},{"ID":16,"TN":"天天","Date":"2015-01-17","Des":"八仙花"},{"ID":18,"TN":"天天","Date":"2015-01-17","Des":"郁金香"},{"ID":19,"TN":"天天","Date":"2015-01-17","Des":"企鵝"},{"ID":20,"TN":"天天","Date":"2015-01-17","Des":"沙漠"},{"ID":21,"TN":"天天","Date":"2015-01-17","Des":"水母"},{"ID":3,"TN":"天天","Date":"2015-01-07","Des":"cvxcvxzcvcvzxcvzzcccccccccccccccc"},{"ID":4,"TN":"天天","Date":"2015-01-07","Des":"dfsadfsadfdfsdfsd"}]}]
這個NSString數據類型的字符串如何轉換成一個NSArry數組?在安卓中是通過getJSONbject("Android")解析出來的

最佳回答:


最後輸出的就是NSArray

         let data = jsonString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
        if data != nil {
            let obj: AnyObject? =  NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: nil)
            if obj!.isKindOfClass(NSArray.classForCoder()) {
                print(obj)
            }

        }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved