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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:35:10+00:00 2026-05-22T01:35:10+00:00

I’m trying to create an app for the iPhone where I pull data from

  • 0

I’m trying to create an app for the iPhone where I pull data from a database and then display it on a table (a completely new view from the main screen in which I ask the user to enter in data). I’ve used this framework to help switch views in my app:
http://www.pushplay.net/2009/05/framework-for-having-multiple-views-in-an-iphone-app/

And basically, I modified it a little bit. I have it implemented fine, but when I populate the table I have to pass the array of information from a class where I pull the data from into the view where I display the table. I found the problem with my code (displayed below).

-(void) displayView:(int)intNewView{
    NSLog(@"%i", intNewView);
    [currentView.view removeFromSuperview];
    [currentView release];

    ServiceProvider *g = [[ServiceProvider alloc] init];
    ServiceProvider *l = [[ServiceProvider alloc] init];

    [g setSPNAME:@"george"];
    [l setSPNAME:@"luuuuuusaaaa"];

    passInTableToTOI = [[NSMutableArray alloc] initWithObjects:g, l, nil];

    ResultsPage *rP = [[ResultsPage alloc] initWithNibName:@"TableOfItems" bundle:[NSBundle mainBundle]];
    TableOfItems *tOI = [[TableOfItems alloc] init];

    switch (intNewView) {
        case 1:
            currentView = [[SearchPage alloc] init];
            break;
        case 2:
            [tOI setPassedThroughTable:passInTableToTOI];
            [rP setResultsTable:tOI];
            currentView = rP;
            break;
        case 3:
            currentView = [[ShowAllPage alloc] init];
            break;
        /*default:
            break;*/
    }

    //[rP release];
    //[tOI release];
    [self.view addSubview:currentView.view];
}

The table gets passed fine, but when I try to display the view I get this error “Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[ResultsPage tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x4e396c0”. I feel like I’m not giving enough information, so please if you’d like more information don’t hesitate. I’m not sure what else I’m being vague on so it’d help to let me know how I can be more specific. Thanks a lot everyone.

[[EDIT 1]]

//===========ResultsPage.h

#import <UIKit/UIKit.h>

@class TopBottomRectangles;
@class TableOfItems;
@class SearchTextBox;

@interface ResultsPage : UIViewController {

    TopBottomRectangles *tbRects;
    TableOfItems *resultsTable;
    SearchTextBox *sTB;

}

@property (nonatomic, retain) IBOutlet TableOfItems *resultsTable;

@end

//===================ResultsPage.m file

#import "ResultsPage.h"
#import "TopBottomRectangles.h"
#import "TableOfItems.h"
#import "SearchTextBox.h"

#import "MultiviewAppDelegate.h"


@implementation ResultsPage
@synthesize resultsTable;

-(void)goToShowAllPage
{
    MultiviewAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    [appDelegate displayView:3];
}

// The designated initializer.  Override if you create the controller programmatically     and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
}
return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a     nib.
- (void)viewDidLoad {

    NSLog(@"load the results page");

    tbRects = [[TopBottomRectangles alloc] init];
    sTB = [[SearchTextBox alloc] init];

[self.view addSubview:[resultsTable view]];
[self.view addSubview:tbRects.bottomBG_View];
[self.view addSubview:tbRects.topBG_View];
[self.view addSubview:sTB.textBox_BG_border];
[self.view addSubview:sTB.textBox_BG];
[self.view addSubview:sTB.textBox];

//[self.view addSubview:btnTwo];

[super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

    - (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 {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    NSLog(@"dealloc results page");
    [sTB release];
    [resultsTable release];
    [tbRects release];
    [super dealloc];
}


@end

[[EDIT 2]]

//====TableOfItems.h file

#import <UIKit/UIKit.h>
@interface TableOfItems : UITableViewController {
    NSMutableArray *listOfItems;
    NSMutableArray *passedThroughTable;
}

@property (nonatomic, retain) NSMutableArray* passedThroughTable;

@end

//=====TableOfItems.m file

#import "TableOfItems.h"
#import "MyTableCell.h"
#import "ServiceProvider.h"


@implementation TableOfItems
@synthesize passedThroughTable;

#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

    self.navigationController.navigationBarHidden = YES;
    //set the size of the table
    [self fixTableSize];

    NSMutableArray *spName = [[NSMutableArray alloc] init];
    for (int i = 0; i < [passedThroughTable count]; i++){

        ServiceProvider *willBeGone = [[ServiceProvider alloc] init];
        willBeGone = [passedThroughTable objectAtIndex:i];
        [spName addObject:willBeGone.SPNAME];

        NSLog(@"%@", [spName objectAtIndex:i]);
        //[willBeGone release];

    }

    //Initialize the array.
    listOfItems = [[NSMutableArray alloc] init];

    NSArray *countriesToLiveInArray = [NSArray arrayWithObjects:@"Iceland", @"Greenland", @"Switzerland", @"Norway", @"New Zealand", @"Greece", @"Rome", @"Ireland", nil];
    NSDictionary *countriesToLiveInDict = [NSDictionary dictionaryWithObject:countriesToLiveInArray forKey:@"Countries"];

    NSArray *countriesLivedInArray = [NSArray arrayWithObjects:@"India", @"U.S.A", nil];
    NSDictionary *countriesLivedInDict = [NSDictionary dictionaryWithObject:countriesLivedInArray forKey:@"Countries"];

    [listOfItems addObject:countriesToLiveInDict];
    [listOfItems addObject:countriesLivedInDict];
}

-(void)fixTableSize{

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    CGFloat screenScale = [[UIScreen mainScreen] scale];

    NSInteger height = screenBounds.size.height * screenScale;
    NSInteger windowHeight = 100;
    NSInteger yFromTop = 60;
    NSInteger yFromBottom = height + 30 - windowHeight;

    self.tableView.frame = CGRectMake(0,yFromTop,320,yFromBottom - yFromTop);

}



#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return [listOfItems count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    NSArray *sectionTitles = [[NSArray alloc] initWithObjects:@"Countries to visit", @"Countries visited", nil];

    return [sectionTitles objectAtIndex:section];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;

    NSLog(@"====");

    //Number of rows it should expect should be based on the section
    NSDictionary *dictionary = [listOfItems objectAtIndex:section];
    NSArray *array = [dictionary objectForKey:@"Countries"];
    return [array count];
}


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

    NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row];
    MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
    NSArray *array = [dictionary objectForKey:@"Countries"];

    if (cell == nil) {
        cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];

        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(1, 1, 30.0, 
                                                                tableView.rowHeight)] autorelease]; 
        [cell addColumn:60];
        //label.tag = FIRCOL_TAG; 
        label.font = [UIFont systemFontOfSize:12.0]; 
        label.text = [NSString stringWithFormat:@"%d:00", indexPath.row];
        label.textAlignment = UITextAlignmentRight; 
        label.textColor = [UIColor blueColor]; 
        label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | 
        UIViewAutoresizingFlexibleTopMargin; 
        [cell.contentView addSubview:label]; 

        label =  [[[UILabel alloc] initWithFrame:CGRectMake(70.0, 0, 110, 
                                                        tableView.rowHeight)] autorelease]; 
        [cell addColumn:260];
        //label.tag = SECCOL_TAG; 
        label.font = [UIFont systemFontOfSize:12.0]; 
        label.text = [NSString stringWithFormat:@"%@", [array objectAtIndex:indexPath.row]];
        label.textAlignment = UITextAlignmentLeft; 
        label.textColor = [UIColor blackColor]; 
        label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | 
        UIViewAutoresizingFlexibleHeight; 
        [cell.contentView addSubview:label];

        label =  [[[UILabel alloc] initWithFrame:CGRectMake(270.0, 0, 30, 
                                                        tableView.rowHeight)] autorelease]; 
        //[cell addColumn:180];
        //label.tag = THIRCOL_TAG; 
        label.font = [UIFont systemFontOfSize:12.0]; 
        // add some silly value
        label.text = [NSString stringWithFormat:@"$%d", indexPath.row * 4];
        label.textAlignment = UITextAlignmentLeft; 
        label.textColor = [UIColor blueColor]; 
        label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | 
        UIViewAutoresizingFlexibleHeight; 
        [cell.contentView addSubview:label];
    }

    return cell;

} 





@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-05-22T01:35:12+00:00Added an answer on May 22, 2026 at 1:35 am

    I found my problem. It was this clause:

        ResultsPage *rP = [[ResultsPage alloc] initWithNibName:@"TableOfItems" bundle:[NSBundle mainBundle]];
        TableOfItems *tOI = [[TableOfItems alloc] init];
    

    It’s supposed to be

        ResultsPage *rP = [[ResultsPage alloc] init];
        TableOfItems *tOI = [[TableOfItems alloc] initWithNibName:@"TableOfItems" bundle:[NSBundle mainBundle]];
    

    I had a .xib file called “TableOfItems” and that should be corresponding to the class that populates the user interface, TableOfItems. This class hass all those delegates which creates the rows and sections and whatnot.

    I’m sorry that I made such a foolish error…I don’t think this would have been easily found by someone who didn’t have access to the .xcodeproj

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.