Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8873983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:36:20+00:00 2026-06-14T18:36:20+00:00

I call a webservice and get a nice JSON in return. This JSON lists

  • 0

I call a webservice and get a nice JSON in return. This JSON lists a couple of reports with category.

The big question is how I can make a nice looking tableview with this, grouped by category. Im new to iOS, and I am really stucked at this point.

I save the json in an array like this:

tableData = [NSJSONSerialization JSONObjectWithData:dataWebService options:kNilOptions error:&error];

And then I sort the list:

NSArray *sortedArray;
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"Category"  ascending:YES];
sortedArray = [tableData sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];

The json I get is this:

{
        Category = Faktura;
        about = "Fakturablankett med giro med utvalg p\U00e5 fra-til fakturanr";
        name = Faktura;
        reportendpoint = "https://unionline.unimicro.no/uni24Report/Report.aspx";
        reportid = 16;
    },
            {
        Category = Faktura;
        about = "Fakturablankett med giro med utvalg p\U00e5 fra-til fakturanr";
        name = "Faktura med sidenummer";
        reportendpoint = "https://unionline.unimicro.no/uni24Report/Report.aspx";
        reportid = 19;
    },
            {
        Category = Faktura;
        about = "Liste over fakturaer med status og mva-detaljer. Utvalg p\U00e5 fra-til fakturanr.";
        name = Fakturajournal;
        reportendpoint = "https://unionline.unimicro.no/uni24Report/Report.aspx";
        reportid = 15;
    },
            {
        Category = "Journaler og Kontoutskrifter";
        about = "";
        name = "Kontoutskrift hovedbok";
        reportendpoint = "https://unionline.unimicro.no/uni24Report/Report.aspx";
        reportid = 4;
    },
            {
        Category = "Journaler og Kontoutskrifter";
        about = "";
        name = "Kontoutskrift kunder";
        reportendpoint = "https://unionline.unimicro.no/uni24Report/Report.aspx";
        reportid = 5;
    }

I would like to list these “name” in a tableview, grouped by “Category”. I need to sort the category an list the reports who belongs to these categories.

There is many more categories, but I didn´t paste them all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:36:21+00:00Added an answer on June 14, 2026 at 6:36 pm

    You have to create one global array which will has list of category arrays.

    To create global array with elements called category-arrays, used didReceiveResponseJson: and nameDitionaryAllReadyExist: methods.

    To view above json data in UITableView:

    NSMutableArray* tableArray;//Declare this array globally and allocate memory in viewdidload
    
    -(NSMutableArray *)nameDitionaryAllReadyExist:(NSString *)name {
    
        for(NSMutableArray *nameArray in tableArray){
    
            for(NSDictionary* nameDict in nameArray) {
                if([[nameDict objectForKey:@"Category"] isEqualToString:name])
    
                    //return the existing array refrence to add
                    return nameArray;
            }
        }
    
        // if we dont found then we will come here and return nil
        return nil;
    }
    
    -(void)didReceiveResponseJson:(NSArray *)jsonArray {
    
        for(NSDictionary* nameDict in jsonArray) {
    
            NSMutableArray* existingNameArray=[self nameDitionaryAllReadyExist:[nameDict objectForKey:@"Category"]];
            if(existingNameArray!=nil) {
                //if name exist add in existing array....
                [existingNameArray addObject:nameDict];
            }
            else {
                // create new name array
                NSMutableArray* newNameArray=[[[NSMutableArray alloc] init] autorelease];
                // Add name dictionary in it
                [newNameArray addObject:nameDict];
    
                // add this newly created nameArray in globalNameArray
                [tableArray addObject:newNameArray];
            }
        }
    
        //so at the end print global array you will get dynamic array with the there respetive dict.
        NSLog(@"Table array %@", tableArray);
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
        tableArray=[[NSMutableArray alloc] init];
    
        NSString* path=[[NSBundle mainBundle] pathForResource:@"JsonData" ofType:@"json"];
    
        NSDictionary* tableData=[NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:kNilOptions error:nil];
    
        //NSLog(@"Table Array- %@",tableData);
    
        NSArray* dataArray = [tableData objectForKey:@"data"];
    
        [self didReceiveResponseJson:dataArray];
    }
    
    #pragma mark
    #pragma mark UITableViewDataSource
    
    //@required
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
        NSArray* array=[tableArray objectAtIndex:section];
        return [array count];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
            NSArray* array=[tableArray objectAtIndex:indexPath.section];
    
            NSDictionary* item=[array objectAtIndex:indexPath.row];
            NSString* name=[item valueForKey:@"name"];
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
        if (cell == nil) {
            // No cell to reuse => create a new one
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"] autorelease];        
            // Initialize cell
        }
    
        // Customize cell
        cell.textLabel.text = name;
    
        return cell;
    }
    
    //@optional
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
        return [tableArray count];
    }
    
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    
            NSArray* array=[tableArray objectAtIndex:section];
        if([array count]) {
            NSDictionary* item=[array objectAtIndex:0];
        return [item valueForKey:@"Category"];
        }
        else
            return nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a JSON from a webservice with javascript $.Ajax call. <script
I want Play to call a webservice. The webservice accepts application/json and returns this
I have the following ajax call to webservice to pass json data and get
I want to call a webservice from jQuery. How can I do that?
I'm using a IHttpHandler to call a webservice and return the resulting byte[] to
I want to call a webservice using jQuery.ajax() but the webervice doesn't get called.
I am trying to call the webservice to get a simple list of tasks,
can any one please tell me how to call a webservice repeatedly for every
I have start a timer which call getMessage webservice which return comming message for
In C#, I am trying to get call a webservice which returns an XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.