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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:43:16+00:00 2026-05-27T12:43:16+00:00

I am a total newbie on iOS development. After numerous tries; with lots of

  • 0

I am a total newbie on iOS development. After numerous tries; with lots of sample codes I managed to parse a json string from my server and able to display the results in a dynamic tableview. My problem is I cannot make the cells clickable so they would pass the id and the label to another view where another json parse will be performed to display the details of the row.

Below is my code:

#import "jsonviewcontroller.h"
#import "CJSONDeserializer.h"
#import "Otel_ItemViewController.h"

@implementation jsonviewcontroller


@synthesize tableview;
@synthesize rows;

- (void)dealloc {
    [rows release];
    [tableview release];
    [super dealloc];

}

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [rows count];
}


// 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];
    }

    // Configure the cell.
    NSDictionary *dict = [rows objectAtIndex: indexPath.row];

    cell.textLabel.text = [dict objectForKey:@"C_NAME"];
    cell.detailTextLabel.text = [dict objectForKey:@"CAT_ID"];


    return cell;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    NSURL *url = [NSURL URLWithString:@"http://zskript.net/categories.php"];
    NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];

    NSLog(jsonreturn); // Look at the console and you can see what the restults are

    NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
    NSError *error = nil;

    // In "real" code you should surround this with try and catch
    NSDictionary * dict = [[[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error] retain];
    if (dict)
    {
        rows = [dict objectForKey:@"users"];
    }

    NSLog(@"Array: %@",rows);


    [jsonreturn release];
}

// Do some customisation of our new view when a table item has been selected
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure we're referring to the correct segue
    if ([[segue identifier] isEqualToString:@"ShowSelectedMovie"]) {

        // Get reference to the destination view controller
        Otel_ItemViewController *vc = [segue destinationViewController];

        // get the selected index
        NSInteger selectedIndex = [[self.tableview indexPathForSelectedRow] row];

        // Pass the name and index of our film
        [vc setSelectedItem:[NSString stringWithFormat:@"%@", [rows objectAtIndex:selectedIndex]]];
        [vc setSelectedIndex:selectedIndex];
    }
}


- (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;
}



@end

And below is the view that will display the detail:

#import "Otel_ItemViewController.h"

@implementation Otel_ItemViewController

@synthesize selectedIndex, selectedItem;

- (void)viewDidLoad
{
    [super viewDidLoad];
    [outputLabel setText:selectedItem];
    [outputText setText:selectedItem];
    [outputImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", selectedIndex]]];
}

@end

Currently, when I click the cells in the table, Although I have set it to push to the next view, nothing happens. Would someone please advise?

Here is the updated code.

My root view controller:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dict = [rows objectAtIndex: indexPath.row];
    DetailViewController *controller = [[DetailViewController alloc] init];
    controller.CATNAME = [dict objectForKey:@"C_NAME"];
    controller.CATNUMBER = [dict objectForKey:@"CAT_ID"];
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

And here is DetailViewController.h:

@interface DetailViewController : UIViewController {


    NSString *CATNAME;
    NSInteger CATNUMBER;
    IBOutlet UILabel *labelId;
    IBOutlet UILabel *LabelName;

}

@property (nonatomic) NSInteger CATNUMBER;
@property (nonatomic, retain) NSString *CATNAME;

@end

And DetailViewController.m:

#import "DetailViewController.h"

@implementation DetailViewController

@synthesize CATNAME, CATNUMBER;


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void) viewDidLoad
{
    LabelName.Text = CATNAME;
    labelId = CATNUMBER;
//    [LabelName setText:CATNAME];
//    [labelId setText:CATNUMBER];
}
  • 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-27T12:43:17+00:00Added an answer on May 27, 2026 at 12:43 pm

    You have to implement this method

    EDIT: Loading a new view

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSDictionary *dict = [rows objectAtIndex: indexPath.row];
        MyNewViewController *controller = [[MyNewViewController alloc] init];
        controller.C_NAME = [dict objectForKey:@"C_NAME"];
        controller.CAT_ID = [dict objectForKey:@"CAT_ID"];
        [self.navigationController pushViewController:controller animated:YES];
        [controller release];
    }
    

    In the code above I assume you are using a navigation controller (which is the easiest way to do what you want to be doing). Also I am assuming you have a class that inherits from UIViewController that you want to have displayed. I am also assuming that this class which I called MyNewViewController in my example has two members and properties called C_NAME and CAT_ID respectively.

    - (void) viewDidLoad
    {
         labelName.Text = C_NAME;
         labelId = CAT_ID
    }
    

    The above my be incorrect as I am doing it out of memory. But the principal stays the same, if you passed the variables correctly it should work, you can have a look at my blog it still needs some work done on it, but it has a nice beginners post and shows how to edit the text of the label. In the code above I am assuming your view contains two labels labelName and labelId respectfully.

    In there you have access to what cell was selected and you can then define what needs to happen.

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

Sidebar

Related Questions

I'm a total newbie at Entity Framework and ASP.Net MVC, having learned mostly from
I am a total newbie in the ipad app development. I am interested in
Hello fellow developers, I am a total newbie in Android development and I am
I am trying to use boost string algorithms for case insensitive search. total newbie
I am a total newbie in Java and Eclipse. I googled for lots of
again a total newbie question from me about Haskell, and Leskah. (First, a subjective
Being a total newbie with Objective-C coming from C#, I keep finding conflicting info
Warning. This is a total newbie question for Groovy.. I'm from a Java background
I'm a total newbie in ios, so judge my question by that. I have
I'm a total newbie for database-based website. I just learned designing website from zero

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.