Press buttons divided by category → List by category in table view (transition to section of category corresponding to pressed button)

Asked 2 years ago, Updated 2 years ago, 88 views

This is my first question.

We are developing an application to introduce a store in a certain area. There are nine buttons on the top page, separated by each category.

List of stores by store category→

For example, if you press a button in the category Restaurant, a list of stores bound to the category (section) of Restaurant will appear in the table view.

So far, JSON has the data to display in the table view locally, and it worked to simply display the data list in the table view.If possible, I would like to use this JSON file as it is and implement the above functions, but would that be possible?

Also, if possible, I would appreciate it if someone could tell me what kind of coding you can think of.



*Additional JSON file example

JSON, I don't know how the array works and I can't explain it well. For example, the following is an example:


"aaa": [

]

{"name":"Restaurant a", "category":"restaurant", "url":"http://-----", "address":"Tokyo -----", "lat":34.000000", "lon":"135.000000000000", "tel."000" {"name":"Restaurant b", "category":"restaurant", "url":"http://-----", "address":"Tokyo -----", "lat":31.00000000", "lon":"131.00000000000000", "tel."000" {"name":"clothes store a", "category":"fashion", "url":"http://-----", "address":"Tokyo -------", "lat":32.000000", "lon":"133.00000000", "tel":":000-pmg }

{"name":"clothes store b", "category":"fashion", "url":"http://-----", "address":"Tokyo -------", "lat":33.000000", "lon":"134.00000000", "tel":000."-pgn" >" >]


"There are about 100 pieces of data lined up like this, and I would like to see a list of categories ""restaurant"" (restaurant a, b...) in the table view, and a list of categories ""fashion"" (clothes store a, b...) in the table view."

ios objective-c xcode json

2022-09-30 19:30

1 Answers

Considering the above comments,
The flow is as follows.
1. Place JSON data in NSDictionary format in NSAray (in the following example, NSDictionary is included in NSMutableArray)

NSMutableArray* allArr = NSMutableArray array;

arr=[@[@{@"name":@"Restaurant a", @"category":@"restaurant"},
@{@"name":@"Restaurant b", @"category":@"restaurant"},
@{@"name":@"Restaurant c", @"category":@"restaurant"},
@{@"name":@"Sports Center a", @"category":@"sports",
@{@"name":@"Sports Center b", @"category":@"sports"}]mutableCopy];

NSMutableArray* restaurantArr = [NSMutableArray array];
for (NSDictionary*dic in allArr) {
  if([dic[@"category"]isEqualToString:@"restaurant"){
    [restaurantArrdObject:dic];
  }
}

RestaurantArr now includes Category: Restaurant Dictionary.


2022-09-30 19:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.