如何在ios中存储类别等数据



我正在开发一个购物应用程序,我有响应数据,例如所有类别 例如,主要类别有男人、女人、孩子等。每个都有子类别,如T恤,衬衫,鞋类等,也有一些子类别(例如鞋类)休闲鞋,正装鞋,凉鞋等。
那么,如何存储此响应以及如何显示一个特定类别?

这是我的回应

{  
   "success":true,
   "category":[  
      {  
         "category_id":"74",
         "parent_id":"0",
         "name":"Grocery",
         "image":"catalog/Rice.jpg",
         "top":"1",
         "column":"1",
         "sort_order":"0",
         "status":"1",
         "date_added":"2015-03-25 11:26:46",
         "date_modified":"2015-04-20 11:04:29",
         "description":"<p><br></p>",
         "meta_title":"Grocery",
         "meta_description":"",
         "meta_keyword":"",
         "store_id":"0",
         "subcategory":[  
            {  
               "category_id":"75",
               "parent_id":"74",
               "name":"Dals & Pulses",
               "image":"catalog/0004620_dm-gram-dal-1kg.png",
               "top":"0",
               "column":"0",
               "sort_order":"1",
               "status":"1",
               "date_added":"2015-03-25 11:42:20",
               "date_modified":"2015-04-20 11:08:24",
               "description":"<p><br></p>",
               "meta_title":"Dals & Pulses",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            },
            {  
               "category_id":"76",
               "parent_id":"74",
               "name":"Dry Fruits & Nuts",
               "image":"catalog/almonds.jpg",
               "top":"0",
               "column":"0",
               "sort_order":"2",
               "status":"1",
               "date_added":"2015-03-25 12:17:39",
               "date_modified":"2015-04-20 11:08:11",
               "description":"<p><br></p>",
               "meta_title":"Dry Fruits & Nuts",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            },
            {  
               "category_id":"77",
               "parent_id":"74",
               "name":"Edible Oil & Ghees",
               "image":"catalog/oil.jpg",
               "top":"0",
               "column":"0",
               "sort_order":"3",
               "status":"1",
               "date_added":"2015-03-25 15:06:06",
               "date_modified":"2015-04-16 18:03:13",
               "description":"<p><br></p>",
               "meta_title":"Edible Oil & Ghees",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            },
            {  
               "category_id":"78",
               "parent_id":"74",
               "name":"Atta & Flour",
               "image":"catalog/aashirvaad-atta-whole-wheat-noworry.jpg",
               "top":"0",
               "column":"0",
               "sort_order":"5",
               "status":"1",
               "date_added":"2015-03-25 16:27:52",
               "date_modified":"2015-04-20 11:04:38",
               "description":"<p><br></p>",
               "meta_title":"Atta & Flour",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            },
            {  
               "category_id":"79",
               "parent_id":"74",
               "name":"Rice",
               "image":"catalog/Rice.jpg",
               "top":"0",
               "column":"0",
               "sort_order":"6",
               "status":"1",
               "date_added":"2015-03-25 16:42:55",
               "date_modified":"2015-04-16 18:03:40",
               "description":"<p><br></p>",
               "meta_title":"Rice",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            },
            {  
               "category_id":"80",
               "parent_id":"74",
               "name":"Salt & Sugar",
               "image":"catalog/Sugar.jpg",
               "top":"0",
               "column":"0",
               "sort_order":"7",
               "status":"1",
               "date_added":"2015-03-25 16:53:12",
               "date_modified":"2015-03-25 20:10:24",
               "description":"<p><br></p>",
               "meta_title":"Salt & Sugar",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            },
            {  
               "category_id":"81",
               "parent_id":"74",
               "name":"Millets",
               "image":"catalog/Millets.JPG",
               "top":"0",
               "column":"0",
               "sort_order":"8",
               "status":"1",
               "date_added":"2015-03-25 17:02:57",
               "date_modified":"2015-04-16 18:04:09",
               "description":"<p><br></p>",
               "meta_title":"Millets",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            }
         ]
      },
      {  
         "category_id":"82",
         "parent_id":"0",
         "name":"chips",
         "image":null,
         "top":"1",
         "column":"1",
         "sort_order":"2",
         "status":"1",
         "date_added":"2015-03-27 18:31:51",
         "date_modified":"2015-04-24 00:01:47",
         "description":"<p>chips are crispy</p>",
         "meta_title":"chips",
         "meta_description":"",
         "meta_keyword":"",
         "store_id":"0",
         "subcategory":[  
            {  
               "category_id":"83",
               "parent_id":"82",
               "name":"lays",
               "image":"catalog/cashew4.jpg",
               "top":"0",
               "column":"0",
               "sort_order":"1",
               "status":"1",
               "date_added":"2015-03-27 18:32:53",
               "date_modified":"2015-04-23 23:45:59",
               "description":"<p>lays</p>",
               "meta_title":"lays",
               "meta_description":"",
               "meta_keyword":"",
               "store_id":"0"
            }
         ]
      },
      {  
         "category_id":"84",
         "parent_id":"0",
         "name":"Food Items",
         "image":"catalog/slide.jpg",
         "top":"1",
         "column":"1",
         "sort_order":"3",
         "status":"1",
         "date_added":"2015-04-26 22:13:21",
         "date_modified":"2015-04-26 22:13:21",
         "description":"Food Items",
         "meta_title":"Food Items",
         "meta_description":"",
         "meta_keyword":"",
         "store_id":"0",
         "subcategory":"null"
      },
      {  
         "category_id":"86",
         "parent_id":"0",
         "name":"HouseHold",
         "image":"catalog/aashirvaad-atta-whole-wheat-noworry.jpg",
         "top":"1",
         "column":"1",
         "sort_order":"5",
         "status":"1",
         "date_added":"2015-04-26 22:36:03",
         "date_modified":"2015-04-26 22:40:46",
         "description":"HouseHold",
         "meta_title":"HouseHold",
         "meta_description":"",
         "meta_keyword":"",
         "store_id":"0",
         "subcategory":"null"
      },
      {  
         "category_id":"85",
         "parent_id":"0",
         "name":"Bread & Diary",
         "image":"catalog/orid dhal 500gm.JPG",
         "top":"1",
         "column":"1",
         "sort_order":"6",
         "status":"1",
         "date_added":"2015-04-26 22:30:14",
         "date_modified":"2015-04-26 22:40:17",
         "description":"Bread & Diary",
         "meta_title":"Bread & Diary",
         "meta_description":"",
         "meta_keyword":"",
         "store_id":"0",
         "subcategory":"null"
      },
      {  
         "category_id":"87",
         "parent_id":"0",
         "name":"Fruits & Vegetables",
         "image":"catalog/cashew4.jpg",
         "top":"1",
         "column":"1",
         "sort_order":"7",
         "status":"1",
         "date_added":"2015-04-26 22:41:52",
         "date_modified":"2015-04-26 22:41:52",
         "description":"Fruits & Vegetables",
         "meta_title":"Fruits & Vegetables",
         "meta_description":"",
         "meta_keyword":"",
         "store_id":"0",
         "subcategory":"null"
      }
   ]
}

您可以在此类中创建类"衣服",您将具有"类别","子类别","标题","图像"等属性。对于"类别",您可以使用typedef枚举。如果要保存对象,请使用 CoreData,请创建具有类似属性的实体并保存数据。

相关内容

  • 没有找到相关文章

最新更新