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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:12:36+00:00 2026-06-10T08:12:36+00:00

The goal of my application is to parse some XML, display one element of

  • 0

The goal of my application is to parse some XML, display one element of the xml in a tableview and then have the user click on the cell, and it pushes to a new table view where the rest of the data for that element is displayed. The first table view that displays only the list works fine, but for some reason I can’t get the push to a new view controller to work. Below is the code I am using. The first view controller displays in a table view; currentCallType. I wan the user to be be able to click on that table cell, then push to a new table view where it displays the units, station and location. Any help would be AWESOME! thanks.

View controller for first tableview:

#import "ThirdViewController.h"
#import "UnitsXMLParser.h"
#import "DetailViewController"

@implementation ThirdViewController
@synthesize unitsTableView;
@synthesize currentCallType, station, location, units;

XMLParser1 *xmlParser;

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[xmlParser units] count];
}

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

static NSString *CellIdentifier = @"Cell";

Units *currentCall = [[xmlParser units] objectAtIndex:indexPath.row];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                   reuseIdentifier:CellIdentifier];

}

// Set up the cell...
cell.textLabel.text = [currentCall currentCallType];

return cell;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 55;
}

#pragma mark -
#pragma mark Table view delegate

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


DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
    [self.navigationController pushViewController:detail animated:YES];

}


#pragma mark - View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];

xmlParser = [[XMLParser1 alloc] loadXMLByURL:@"http://localhost:8888/units.xml"];

}

XML Parser:

#import <Foundation/Foundation.h>
#import "UnitsXMLParser.h"

@implementation XMLParser1
@synthesize units = _units;


NSMutableString *currentNodeContent;
NSXMLParser     *parser;
Units       *currentCall;
bool            isStatus;

-(id) loadXMLByURL:(NSString *)urlString
{
_units          = [[NSMutableArray alloc] init];
NSURL *url      = [NSURL URLWithString:urlString];
NSData  *data   = [[NSData alloc] initWithContentsOfURL:url];
parser          = [[NSXMLParser alloc] initWithData:data];
parser.delegate = self;
[parser parse];
return self;
}

- (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
currentNodeContent = (NSMutableString *) [string     stringByReplacingOccurrencesOfString:@"~" withString:@""];
}

- (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementname isEqualToString:@"station"])
{
    currentCall = [Units alloc];
    isStatus = YES;
}
}

- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:    (NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if (isStatus)
{
    if ([elementname isEqualToString:@"units"])
    {
        currentCall.units = currentNodeContent;
    }
    if ([elementname isEqualToString:@"name"])
    {
        currentCall.currentCallType = currentNodeContent;
    }
    if ([elementname isEqualToString:@"stationid"])
    {
        currentCall.station = currentNodeContent;
    }
    if ([elementname isEqualToString:@"address"])
    {
        currentCall.location = currentNodeContent;
    }
}
if ([elementname isEqualToString:@"station"])
{
    [self.units addObject:currentCall];
    currentCall = nil;
    currentNodeContent = nil;
}
}
@end
  • 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-10T08:12:38+00:00Added an answer on June 10, 2026 at 8:12 am

    A longshot; but do you have your project configured to use a UINavigationController ? Your view controllers will not be contained in / managed by a UINavigationController unless you start with the correct project template or manually add the UINavigationController . If the view controller containing your posted code is not backed by a navigation controller, [self.navigationController pushViewController:detail animated:YES] will do nothing.

    Also, make sure that you have hooked up your UITableViewDelegate in addition to your UITableViewDataSource , so that your code will catch the row selection.

    I only ask because you do not explicitly state that you have set up your project to use a UINavigationController or confirm that you have hooked up both the delegate and datasource in Interface Builder.

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

Sidebar

Related Questions

I have made one application which can parse the given xml file independent of
My goal is to have more themes for my application and if possible, bundle
I have an application thats main goal is to play a specific video file.
I have GPS Tracking application main goal is saving GPS coordinate to backed database
I'm currently developing a camera application for Android on which some problems have occurred.
Goal : Our application is built using multiple types (e.g. Person, PersonSite(ICollection), Site -
The goal is to implement a web application that can execute methods of .class
My goal is to deploy a simple rails application on a windows server using
My goal is to control an application from VB.NET . There is no API,
The goal here is maximum conversion of users to an application. I tried to

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.