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

  • Home
  • SEARCH
  • 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 6178607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:29:07+00:00 2026-05-24T00:29:07+00:00

I find this sample code and i modified the code to make it do

  • 0

I find this sample code and i modified the code to make it do what i want.
The tableview load data from a plist, it works
datas are displayed in sections, it works
now when a row is selected, i want to push a Detailviewcontroller to show more details.
Grrrr, it does not work, and i don’t know why.
The difference between this code and a other one where it works fine, is that ICB_SectionedTableViewDemoViewController is declared as a class in the appDelegate and i don’t know if it as an incidence when i want to push the DetailViewController.

here is the code of my rootController named ICB_SectionedTableViewDemoViewController.m

//  ICB_SectionedTableViewDemoViewController.m
//  ICB_SectionedTableViewDemo
//
//  Created by Matt Tuzzolo on 12/10/10.
//  Copyright 2010 ELC Technologies. All rights reserved.
//

#import "ICB_SectionedTableViewDemoViewController.h"
#import "ICB_SectionedTableViewDemoAppDelegate.h"
#import "DetailViewController.h"



@implementation ICB_SectionedTableViewDemoViewController

@synthesize books, sections ;

- (void)viewDidLoad {

    self.books = [NSMutableArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"books" ofType:@"plist"]];
    self.sections = [[NSMutableDictionary alloc] init];

    BOOL found;

    // Loop through the books and create our keys
    for (NSDictionary *book in self.books)
    {        
        NSString *c = [[book objectForKey:@"author"] substringToIndex:1];

        found = NO;

        for (NSString *str in [self.sections allKeys])
        {
            if ([str isEqualToString:c])
            {
                found = YES;
            }
        }

        if (!found)
        {     
            [self.sections setValue:[[NSMutableArray alloc] init] forKey:c];
        }
    }

    // Loop again and sort the books into their respective keys
    for (NSDictionary *book in self.books)
    {
        [[self.sections objectForKey:[[book objectForKey:@"author"] substringToIndex:1]] addObject:book];
    }    

    // Sort each section array
    for (NSString *key in [self.sections allKeys])
    {
        [[self.sections objectForKey:key] sortUsingDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"author" ascending:YES]]];
    }    

    [super viewDidLoad];
}

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{
    return [[self.sections allKeys] count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{    
    if(section == 0)
        return @"COULEURS";
    else
        return @"MOTIFS";    

  //  return [[[self.sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:section];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
    return [[self.sections valueForKey:[[[self.sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:section]] count];
}

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return [[self.sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

    NSDictionary *book = [[self.sections valueForKey:[[[self.sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];

    cell.textLabel.text = [book objectForKey:@"title"];    
    cell.detailTextLabel.text = [book objectForKey:@"description"];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {



    //Initialize the detail view controller and display it.
    DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
    dvController.CL = [self.books objectAtIndex:indexPath.row];
    [self.navigationController pushViewController:dvController animated:YES];
 //   [self presentModalViewController:dvController animated:YES];
 //   [self.view addSubview:dvController.view];
    [dvController release];



}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

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


- (void)dealloc {
    [super dealloc];
}

@end

thanks for your very useful help and remind that i’m beginner and my first language is Franch.

  • 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-05-24T00:29:08+00:00Added an answer on May 24, 2026 at 12:29 am

    After having a look at the project, it seems that you did not create a UINavigationController. So, I suggest you to use this code for application:didFinishLaunchingWithOptions::

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
        UINavigationController* navigation = [[UINavigationController alloc] init];
        [navigation pushViewController:viewController animated:NO];
        [window addSubview:navigation.view];
    
        [self.window makeKeyAndVisible];
    
        return YES;
     }
    

    Here, a UINavigationController is instantiated and your first (root) controller is pushed on to it.

    Important: your app has more problems, so it will not work, but at least your DetailView controller will be loaded and attempted to display. About the issues I found:

    1. in didSelectRowAtIndexPath you are using the wrong nib name;

    2. in DetailViewController‘s viewDidLoad you are using a property CL.title which is not defined;

    once you fix those problems, possibly the detail view will show up.

    OLD ANSWER:

    Set a breakpoint in tableView:didSelectRowAtIndexPath: and check that your DetailViewController is created correctly and also that self.navigationController is not nil.

    Alternatively you can add NSLog traces to your code (this is an important debugging technique):

     - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
        //Initialize the detail view controller and display it.
        DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
        dvController.CL = [self.books objectAtIndex:indexPath.row];
        [self.navigationController pushViewController:dvController animated:YES];
    
        NSLog(@"navController: %@", [self.navigationController description]);
        NSLog(@"dvController.CL: %@", [dvController.CL description]);
    
    
     //   [self presentModalViewController:dvController animated:YES];
     //   [self.view addSubview:dvController.view];
       [dvController release];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I find this link everywhere for SQLite sample code ( http://developer.apple.com/library/ios/#samplecode/SQLiteBooks/index.html ) but either
I look many sample code for storing data into sqlite but it work .How
i've built this sample code based on a real problem I have in an
I'm trying to make my program read/write in a database. I found this sample
I searched google but couldn't find an answer to this rather simple question. I
This is a simple question yet I was unable to find any information at
Im sure this is pretty simple but I just cant seem to find the
I think this is a simple question, but I can not find the answer
I feel as though this this is a simple question, but can't find an
This is probably a simple answer but I can't find it. I have a

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.