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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:22:28+00:00 2026-05-23T23:22:28+00:00

I have created a controller class named TAddAlarmController which has a tableview which consists

  • 0

I have created a controller class named TAddAlarmController which has a tableview which consists of 6 rows. When I click on the second row it navigates to a page which is a new controller name TAlarmNewController which is a tableviewcontroller and in which I have created a nsmutablearray and populated that array with 7 static values so when the second controller is displayed the tableview is displayed with 7 static values in it.

I want that when I click on any row of second controller the value that is present inside the cell of the paticular row should be set to detailtextlabel of the previouscontroller i.e TAddAlarmController.

This is my code:

This is AddAlarmcontroller.h

    #import <UIKit/UIKit.h>

    @class StopSnoozeAppDelegate;
    @class Alarm;
    @class TAlarmNewController;
    @interface TAddAlarmController : UITableViewController {

        StopSnoozeAppDelegate *app;
        IBOutlet UITableView *tblView;
        NSDateFormatter *dateFormatter;
        NSUndoManager *undoManager;
        Alarm *am;
        TAlarmNewController *anew;
    }
    @property(nonatomic,retain)NSDateFormatter *dateFormatter;
    @property (nonatomic,retain)Alarm *am;
    @property (nonatomic,retain)NSUndoManager *undoManager;
    @end

This is my .m file

    #import "TAddAlarmController.h"

    #import "Alarm.h"
    #import "TAlarmNewController.h"


    @implementation TAddAlarmController
    @synthesize dateFormatter;
    @synthesize am;
    @synthesize undoManager;



    #pragma mark -
    #pragma mark View lifecycle




    - (void)viewDidUnload {
        // Release any properties that are loaded in viewDidLoad or can be recreated lazily.
        self.dateFormatter = nil;
    }


    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [self.tableView reloadData]; 
    }


    #pragma mark -
    #pragma mark Table view data source

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


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


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




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

        static NSString *CellIdentifier = @"Cell";
        /*
         Dequeue or create and then configure a table cell for each attribute of the book.
         */
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
            //cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }


        switch (indexPath.row) {
            case 0: 
                cell.textLabel.text = @"Time";
                break;
            case 1: 
                cell.textLabel.text = @"Repeat";
                break;
            case 2:
                cell.textLabel.text = @"Sound";
                break;

            case 3:
                cell.textLabel.text = @"Snooze Interval";
                break;

            case 4:
                cell.textLabel.text = @"Alarm Message";
                break;

            case 5:
                cell.textLabel.text = @"Snooze Penalty";
                break;
        }
        return cell;
    }




    #pragma mark -
    #pragma mark Table view delegate

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




        TAlarmNewController *controller = [[TAlarmNewController alloc]initWithNibName:@"TAlarmNewController" bundle:nil];

        switch (indexPath.row) {
            case 0:
                controller.editedObject = @"Time";

                break;
            case 1:

                [self.navigationController pushViewController:controller animated:YES];
                [controller release];

            default:
                break;
        }

     }




    - (NSDateFormatter *)dateFormatter {    
        if (dateFormatter == nil) {
            dateFormatter = [[NSDateFormatter alloc] init];
            //[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
            [dateFormatter setTimeStyle:NSDateFormatterNoStyle];
        }
        return dateFormatter;
    }

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


    @end

This is TAlarmNewController.h

    @class TAddAlarmController;

    @interface TAlarmNewController : UITableViewController {
        IBOutlet UITableView *tblView;
        UIDatePicker *datePicker;
        id editedObject;


            TAddAlarmController *Addalarm;


        NSMutableArray *days;//this is the array where i am storing 7 values statically

    }
    @property (nonatomic,retain) IBOutlet UITableView *tblView;
    @property(nonatomic,retain) IBOutlet UIDatePicker *datePicker;

    @property (nonatomic, retain) id editedObject;
    @property(nonatomic,retain)NSMutableArray *days;
    @property (nonatomic, retain, readonly) TAddAlarmController *Addalarm;
    -(IBAction)cancel;
    -(IBAction)save;
    @end

This is my .m file

    #import "TAlarmNewController.h"

    #import "TAddAlarmController.h"


    @implementation TAlarmNewController

    @synthesize  editedObject,datePicker, tblView,days,Addalarm;

    #pragma mark -
    #pragma mark View lifecycle


    - (void)viewDidLoad {

        UIBarButtonItem * saveButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(save)];
        self.navigationItem.rightBarButtonItem = saveButton;
        [saveButton release];

        UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
        self.navigationItem.leftBarButtonItem = cancelButton;
        [cancelButton release];

        days =[[NSMutableArray alloc]initWithObjects:@"Every Monday",@"Every Tuesday",@"Every Wednesday",@"Every Thursday",@"Every Friday",@"Every Saturday",@"Every Sunday0",nil];

        [super viewDidLoad];


    }


    - (TAddAlarmController *)Addalarm {
        if (Addalarm == nil) {
            Addalarm = [[TAddAlarmController alloc] initWithStyle:UITableViewStyleGrouped];
        }
        return Addalarm;
    }



    -(IBAction)save{

        [self.navigationController popViewControllerAnimated:YES];
    //
    }

    -(IBAction)cancel{
        [self.navigationController popViewControllerAnimated:YES];
    }



    #pragma mark -
    #pragma mark Table view data source

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


    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        // Return the number of rows in the section.
        return [days 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:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }

        cell.textLabel.text = [days objectAtIndex:indexPath.row];
        // Configure the cell...

        return cell;
    }





    #pragma mark -
    #pragma mark Table view delegate

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

    }




    - (void)dealloc {
        [datePicker 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-23T23:22:29+00:00Added an answer on May 23, 2026 at 11:22 pm

    In your FirstViewController

    1, keep a member variable(NSString) named detailTextValueFromSecondController.

    2, create a function named

    -(void)refreshTableToSetDetailText:(NSString *)detailTextValue
    

    Then in your SecondViewController

    Inside

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

    place the following code:

    for (int i =0; i < [[self.navigationController viewControllers] count]; i++)
                {
                    UIViewController *aController = [[self.navigationController viewControllers] objectAtIndex:i];
    
                    if ([aController isKindOfClass:[FirstViewController class]])
                    {
                       FirstViewController *aFirstViewController = (FirstViewController *)aController;
                       [aFirstViewController refreshTableToSetDetailText:yourstringtosetondetaillabel];
            [self.navigationController popToViewController:aController animated:YES];
                    }
    
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a UserControl that has a ListView in it. The ListView is
I have created a C# class file by using a XSD-file as an input.
I have a namespaced controller for some admin functionality. My create form does not
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside
I have created a few small flash widgets that stream .mp3 audio from an
i have created a workflow activity that do give the item creater of a
As mentioned in the Zend Framework manual , I created a base controller. Subclassing

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.