需要处理的JSON数据中一个数组元素如下,请问如何定义一个类获取它的数据(目的是把获取的数据展示在一个tableview的cell中),我需要获取text,user里的screen name和profile_image_url所指向的图像数据。我遇到的问题是在定义一个这样的类时,user是不是要再定义一个类?在类里不能镶嵌一个类吧?如何定义它才能在后续处理中成功地将数据加载在tableview中?
{
"created_at": "Wed May 22 17:18:51 +0800 2013",
"id": 3580806792992860,
"mid": "3580806792992860",
"idstr": "3580806792992860",
"text": "服务器【星耀银河】国家【燕】 浮沉江山英雄定,新的征程从五月十七号重新开始,谁将能主宰星耀银河,谁又将是新兴的霸主? 随着一声惊雷,小史降临到了燕国这片热土上,呼吸着新鲜的空……看全文点这 http://t.cn/zHy3fnC",
"source": "<a href=\"http://app.weibo.com/t/feed/4ZcXia\" rel=\"nofollow\">征途2国史应用</a>",
"favorited": false,
"truncated": false,
"in_reply_to_status_id": "",
"in_reply_to_user_id": "",
"in_reply_to_screen_name": "",
"pic_urls": [],
"geo": null,
"user": {
"id": 2866880570,
"idstr": "2866880570",
"screen_name": "开心惊玄",
"name": "开心惊玄",
"province": "33",
"city": "10",
"location": "浙江 台州",
"description": "",
"url": "",
"profile_image_url": "http://course.gdou.com/gxk/html/hw/1.jpg",
"profile_url": "u/2866880570",
"domain": "",
"weihao": "",
"gender": "m",
"followers_count": 131,
"friends_count": 239,
"statuses_count": 229,
"favourites_count": 0,
"created_at": "Wed Jul 11 19:16:18 +0800 2012",
"following": false,
"allow_all_act_msg": false,
"geo_enabled": true,
"verified": false,
"verified_type": -1,
"remark": "",
"allow_all_comment": true,
"avatar_large": "http://course.gdou.com/gxk/html/hw/2866880570180399998954401.jpg",
"verified_reason": "",
"follow_me": false,
"online_status": 0,
"bi_followers_count": 91,
"lang": "zh-cn",
"star": 0,
"mbtype": 0,
"mbrank": 0,
"block_word": 0
},
"reposts_count": 0,
"comments_count": 0,
"attitudes_count": 0,
"mlevel": 0,
"visible": {
"type": 0,
"list_id": 0
}
},
User是需要再定义一下类的.
一个 swift 文件是可以有多个类的;