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 7847799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:00:18+00:00 2026-06-02T18:00:18+00:00

*** Updated Question ** * *** The JSON data is the Gym Classes for

  • 0

***Updated Question ******
The JSON data is the Gym Classes for all week .

At the moment I am downloading and saved the JSON data to An NSObject SearchResult then display on my UItableviewController one row per gym Class.

But I want to Group items (Gym Classes) By Day and display each day on is own table.

So my question is do I need to group items by date “DAY_OF_WEEK” and store each day in to is own array (MonArray … SunArray)?

or collect all the data Like I am doing now and sort the array in to groups for each day?

I hope this make sense.

thanks for your help .

- (void)viewDidLoad {

[super viewDidLoad];

dispatch_async(kBgQueue, ^{
    NSData* data = [NSData dataWithContentsOfURL: JsonURL];
    [self performSelectorOnMainThread:@selector(fetchedData:)
                           withObject:data waitUntilDone:YES]; });  }

-(SearchResult *)parseTrack:(NSDictionary *)dictionary {
SearchResult *searchResult1 = [[SearchResult alloc] init];
searchResult1.day = [[dictionary objectForKey:@"post"] objectForKey:@"DAY_OF_WEEK"];
searchResult1.classType= [[dictionary objectForKey:@"post"] objectForKey:@"CLASS_TYPE"];
return searchResult1;
}


- (void)fetchedData:(NSData *)responseData { //parse out the json data

searchResults2 = [NSMutableArray arrayWithCapacity:10];

NSError* error;
NSDictionary* dictionary = [NSJSONSerialization
                      JSONObjectWithData:responseData //1 
                            options:kNilOptions error:&error];
NSArray *array = [dictionary objectForKey:@"posts"];

NSLog(@"array : %@",array);

if (array == nil) {
    NSLog(@"Expected 'posts' array");
    return;
}
for (NSDictionary *resultDict in array) {

    SearchResult *searchResult3;

    searchResult3 = [self parseTrack:resultDict];

    if (searchResult3 != nil) {
        [searchResults2 addObject:searchResult3];
    }

    NSLog(@"day: %@, class: %@", [[resultDict objectForKey:@"post"] objectForKey:@"DAY_OF_WEEK"], [[resultDict objectForKey:@"post"] objectForKey:@"CLASS_TYPE"]);

}

[self.tableView reloadData];


}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


 #pragma mark - Table view data source

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {

// Return the number of sections.
return 1;
}

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {

// Return the number of rows in the section.
return searchResults2.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

SRCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SRCell1"];


// Configure the cell...


SearchResult *searchResult1 = [searchResults2 objectAtIndex:indexPath.row];
cell.daynameLabel.text = searchResult1.day;

return cell;
}

JSON output NSlog

2012-04-26 06:12:51.256 passingdata[91699:fb03] array : (
    {
    post =         {
        "CLASS_LEVEL" = "Intro/General";
        "CLASS_TYPE" = "Muay Thai";
        "DAY_OF_WEEK" = Friday;
        ID = 19;
        "ORDER_BY" = 5;
        TIME = "1:00pm - 2:30pm";
    };
}
    {
    post =         {
        "CLASS_LEVEL" = "General/Intermediate/Advanced";
        "CLASS_TYPE" = "Muay Thai Spar - Competitive";
        "DAY_OF_WEEK" = Friday;
        ID = 27;
        "ORDER_BY" = 5;
        TIME = "6:00pm - 9:00pm";
    };
},
    {
    post =         {
        "CLASS_LEVEL" = "Fighters/Advanced/Intermediate";
        "CLASS_TYPE" = "Fighters Training";
        "DAY_OF_WEEK" = Monday;
        ID = 1;
        "ORDER_BY" = 1;
        TIME = "9:30am - 11:00pm";
    };
},
  • 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-02T18:00:21+00:00Added an answer on June 2, 2026 at 6:00 pm
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"DAY_OF_WEEK" ascending:TRUE];
    [sourceArr sortUsingDescriptors:[NSArray arrayWithObjects:sortDescriptor, nil]];
    

    May this will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Updated question given Andrew Hare's correct answer: Given the following C# classes: public class
Updated Question: $(this).attr(EmployeeId, 'A42345'); $.ajax({ type: POST, url: url, data: {EmployeeId: ' + id
UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom
When I get some json data I want to display them in the page
I have another JSON array related question. How would I access the data stored
UPDATED QUESTION Since the ctor is not supported by .NETCF (public FileStream(IntPtr handle, FileAccess
Updated question, see below I'm starting a new project and I would like to
UPDATED QUESTION: Ok, I am going to simplify my question since I don't really
Updated question: Django is giving me the following sql query: SELECT auth_user.id, auth_user.username, auth_user.first_name,
ORIGINAL (see UPDATED QUESTION below) I am designing a new laboratory database that tests

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.