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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:39:46+00:00 2026-05-17T02:39:46+00:00

I’m starting with the SDK and I am trying to set an app using

  • 0

I’m starting with the SDK and I am trying to set an app using a tableview to display the info.

I created a window base application and Im using a tab bar with a tableview that has a navigation bar to go back and forward in it, and it works fine “apparently”, but I am having The problem that Whenever you tap the first row of each (1,2,3…) section it calls the first row of the first section on and on, and I have done a lot of research: tutorials, books, forums, but cant seem to find a way to make it work. I found a lot of good information although that helped me a lot, but wouldn’t fix my problem. I have been fitting with it for days and days.

So having tried all the resources that I was able to find I cry to you for help.

Here is the code I attempt to use, I think it would be of some help to some of you ether.

// Im using This in the
MyTableViewController.h {

#import <UIKit/UIKit.h>
#import "firstCustomCell.h"

@interface MyTableViewController : UITableViewController <UITableViewDelegate,UITableViewDataSource> {

IBOutlet UITableView *theTableView;
NSMutableArray *firstArray;
NSMutableArray *secondArray;
NSMutableArray *thirdArray;
NSMutableArray *listOfItems; 
  }

   @property (nonatomic, retain) NSMutableArray *firstArray;
   @property (nonatomic, retain) NSMutableArray *secondArray;
   @property (nonatomic, retain) NSMutableArray *thirdArray;
   @property (nonatomic, retain) NSMutableArray *listOfItems;

   @end

   }

// Then in the implementation Im using This: tableViewController.m

#import "MyTableViewController.h"
#import "One.h"
#import "Two.h"
#import "Three.h"
#import "Four.h"
#import "Five.h"
#import "Six.h"
#import "Seven.h"
#import "Eight.h"
#import "Nine.h"
#import "Ten.h"
#import "Eleven.h"
#import "Twelve.h"

@implementation MyTableViewController

@synthesize firstArray;
@synthesize secondArray;
@synthesize thirdArray;
@synthesize listOfItems;

#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {
[super viewDidLoad];

listOfItems = [[NSMutableArray alloc]init];

firstArray = [[NSMutableArray alloc]init];
[firstArray addObject:@"Week One"];
[firstArray addObject:@"Week Two"];
[firstArray addObject:@"Week Three"];


NSDictionary *firstDic = [NSDictionary dictionaryWithObject:firstArray forKey:@"CompoNente"];

secondArray = [[NSMutableArray alloc]init];
[secondArray addObject:@"Week Four"];
[secondArray addObject:@"Week Five"];
[secondArray addObject:@"Week Six"];
[secondArray addObject:@"Week Seven"];


NSDictionary *secondDic = [NSDictionary dictionaryWithObject:secondArray forKey:@"CompoNente"];

thirdArray = [[NSMutableArray alloc]init];
[thirdArray addObject:@"Week Eight"];
[thirdArray addObject:@"Week Nine"];
[thirdArray addObject:@"Week Ten"];
[thirdArray addObject:@"Week Eleven"];
[thirdArray addObject:@"Week Twelve"];

NSDictionary *thirdDic = [NSDictionary dictionaryWithObject:thirdArray forKey:@"CompoNente"];


[listOfItems addObject:firstDic];
[listOfItems addObject:secondDic];
[listOfItems addObject:thirdDic];


self.title = NSLocalizedString(@"TableView", @"My favorite TableView");




#pragma mark -
#pragma mark Table view data source

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



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  {
// Return the number of rows in the section.

NSDictionary *dictionary = [listOfItems objectAtIndex:section];
NSArray *array = [dictionary objectForKey:@"CompoNente"];
return [array count];

// Customize the appearance of table view cells.

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

static NSString *CellIdentifier = @"ScustomCell";

firstCustomCell *cell = (firstCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

NSLog(@"Cell created");

NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"firstCustomCell" owner:nil options:nil];

for(id currentObject in nibObjects) {

if ([currentObject isKindOfClass:[firstCustomCell class]]) {
 cell = (firstCustomCell *)currentObject;
}

}
  }

 switch (indexPath.row) {
  case 0:
   (indexPath.section == 0, indexPath.row == 0);
   [[cell currentNameLabel] setText:@"Week One"];
   [[cell imageView] setImage:[UIImage imageNamed:@"1.png"]];
   break;
  case 1:
   (indexPath.section == 0, indexPath.row == 1);
   [[cell currentNameLabel] setText:@"Week Two"];
   [[cell imageView] setImage:[UIImage imageNamed:@"2.png"]];
   break;
  case 2: 
   (indexPath.section == 0, indexPath.row %12 == 2);
   [[cell currentNameLabel] setText:@"Week Three"];
   [[cell imageView] setImage:[UIImage imageNamed:@"3.png"]];
   break;
  case 3:
   (indexPath.section == 1, indexPath.row %12 == 0);
   [[cell currentNameLabel] setText:@"Week Four"];
   [[cell imageView] setImage:[UIImage imageNamed:@"4.png"]];
   break;
  case 4:
   (indexPath.section == 1, indexPath.row %12 == 1);
   [[cell currentNameLabel] setText:@"Week Five"];
   [[cell imageView] setImage:[UIImage imageNamed:@"5.png"]];
   break;
  case 5:
   (indexPath.section == 1, indexPath.row %12 == 2);
   [[cell currentNameLabel] setText:@"Week Six"];
   [[cell imageView] setImage:[UIImage imageNamed:@"6.png"]];
   break;
  case 6:
   (indexPath.section == 1, indexPath.row %12 == 3);
   [[cell currentNameLabel] setText:@"Week Seven"];
   [[cell imageView] setImage:[UIImage imageNamed:@"7.png"]];
   break;
  case 7:
   (indexPath.section == 2, indexPath.row %12 == 0);
   [[cell currentNameLabel] setText:@"Week Eight"];
   [[cell imageView] setImage:[UIImage imageNamed:@"8.png"]];
   break;
  case 8:
   (indexPath.section == 2, indexPath.row %12 == 1);
   [[cell currentNameLabel] setText:@"Week Nine"];
   [[cell imageView] setImage:[UIImage imageNamed:@"9.png"]];
   break;
  case 9:
   (indexPath.section == 2, indexPath.row %12 == 2);
   [[cell currentNameLabel] setText:@"Week Ten"];
   [[cell imageView] setImage:[UIImage imageNamed:@"10.png"]];
   break;
  case 10:
   (indexPath.section == 2, indexPath.row %12 == 3);
   [[cell currentNameLabel] setText:@"Week Eleven"];
   [[cell imageView] setImage:[UIImage imageNamed:@"11.png"]];
   break;
  case 11:
   (indexPath.section == 2, indexPath.row %12 == 4);
   [[cell currentNameLabel] setText:@"Week Twelve"];
   [[cell imageView] setImage:[UIImage imageNamed:@"12.png"]];
   break;

 }

// Configure the cell…

NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"CompoNente"];
NSString *cellValue = [array objectAtIndex:indexPath.row];

cell.text = cellValue; //also receive a warning that setText is deprecated.


return cell;

}   

//Then the delegate

#pragma mark -
#pragma mark Table view delegate

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

 [tableView deselectRowAtIndexPath:indexPath animated:YES];

 if ([[firstArray objectAtIndex:indexPath.row] isEqual: @"Week One"]) {

  One *one = [[One alloc]initWithNibName:@"One" bundle:nil];
  [self.navigationController pushViewController:one animated:YES];
  [one release];

 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Two"]) {

  Two *two = [[Two alloc]initWithNibName:@"Two" bundle:nil];
  [self.navigationController pushViewController:two animated:YES];
  [two release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Three"]) {

   Three *three = [[Three alloc]initWithNibName:@"Three" bundle:nil];
  [self.navigationController pushViewController:three animated:YES];
  [three release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Four"]) {

  Four *four = [[Four alloc]initWithNibName:@"Four" bundle:nil];
  [self.navigationController pushViewController:four animated:YES];
  [four release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Five"]) {

  Five *five = [[Five alloc]initWithNibName:@"Five" bundle:nil];
  [self.navigationController pushViewController:five animated:YES];
  [five release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Six"]) {

  Six *six = [[Six alloc]initWithNibName:@"Six" bundle:nil];
  [self.navigationController pushViewController:six animated:YES];
  [six release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Seven"]) {

  Seven *seven = [[Seven alloc]initWithNibName:@"Seven" bundle:nil];
  [self.navigationController pushViewController:seven animated:YES];
  [seven release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Eight"]) {

  Eight *eight = [[Eight alloc]initWithNibName:@"Eight" bundle:nil];
  [self.navigationController pushViewController:eight animated:YES];
  [eight release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Nine"]) {

  Nine *nine = [[Nine alloc]initWithNibName:@"Nine" bundle:nil];
  [self.navigationController pushViewController:nine animated:YES];
  [nine release]; 
 }


 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Ten"]) {

  Ten *ten = [[Ten alloc]initWithNibName:@"Ten" bundle:nil];
  [self.navigationController pushViewController:ten animated:YES];
  [ten release]; 
 }

 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Eleven"]) {

  Eleven *eleven = [[Eleven alloc]initWithNibName:@"Eleven" bundle:nil];
  [self.navigationController pushViewController:eleven animated:YES];
  [eleven release]; 
 }
 else if ([[firstArray objectAtIndex:indexPath.row] isEqual:@"Week Twelve"]) {

  Twelve *twelve = [[Twelve alloc]initWithNibName:@"Twelve" bundle:nil];
  [self.navigationController pushViewController:twelve animated:YES];
  [twelve release]; 
 }
}

//adding the headers for sections

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

if (section == 0)
 return @"FIRST SECTION";

 else if (section == 1)
  return @"SECOND SECTION";

 else if (section == 2)
  return @"THIRD SECTION";

} // also receive a warning "Control reaches end of non-void function"

//Release or clean memory And finishing TableView

#pragma mark -
#pragma mark Memory management

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

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

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
 [listOfItems release];
 [thirdArray release];
 [secondArray release];
 [firstArray release];
    [super dealloc];
}


@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-17T02:39:47+00:00Added an answer on May 17, 2026 at 2:39 am

    Yeah I always have this problem – I’m not sure what it is but I think its something to do with the fact that == 0 is also == NO or == false, but I’m not sure.

    What usually works for me is treating it like an integer, so:

    if([indexPath section] < 1){
      // section 0
    }
    else if([indexPath section] > 0 && [indexPath section] < 2){
      // section 1
    }
    else{
      // etc...
    }
    

    or you could convert it to an NSString

    NSString *section = [NSString stringWithFormat:@"%i",[indexPath section]];
    

    and then do a string comparison:

    if([section isEqualToString:@"0"]){
      // first section
    }
    else if([section isEqualToString:@"1"]){
      // next section
    }
    else {
      // etc...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

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.