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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:27:20+00:00 2026-05-25T10:27:20+00:00

In addAlarm Controller, I am declaring an NSString as below, NSString *nameOfAlarm; // in

  • 0

In addAlarm Controller, I am declaring an NSString as below,

   NSString *nameOfAlarm; // in .h

  @property (nonatomic, retain) NSString *nameOfAlarm; //in .h

  @synthesize nameOfAlarm; //in .m

and In ViewDidLoad, I am initializing it as following

  nameOfAlarm = [[NSString alloc] initWithString:@"Alarm"];//In ViewDidLoad

then after I am doing something like below

    // Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d", indexPath.section, indexPath.row];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

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

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
   // Configure the cell...

if (indexPath.section == 0) {
    UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
    cell.accessoryView = mySwitch;
    [(UISwitch *)cell.accessoryView setOn:YES];   // Or NO, obviously!
    [(UISwitch *)cell.accessoryView addTarget:self action:@selector(mySelector:)
                             forControlEvents:UIControlEventValueChanged];
    NSString *cellValue = [NSString stringWithFormat:@"Enable Alarm"];
    cell.textLabel.text = cellValue;
    //return cell;      
}
if (indexPath.section == 1) {
    if (indexPath.row == 0) {
        NSString *cellValue = [NSString stringWithFormat:@"Name "];
        cell.textLabel.text = cellValue;

        NSString *cellValue2 = [NSString stringWithFormat:@"%@",(NSString*)nameOfAlarm];
        cell.detailTextLabel.text = cellValue2;

    }

so I am doing reload table in ViewWillAppear as below

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(@"ViewWillAppear, The name is  %@",nameOfAlarm);
[self.tableView reloadData];
 }

I am writing delegate method which is being called by other controller as followed,

- (void) processName: (NSString *)n{
nameOfAlarm = (NSString *)n;
NSLog(@"Name is %@",nameOfAlarm);
}

Now when I click on 0 index of row, it will go to Name controller, simply, the .h of name controller is

#import <UIKit/UIKit.h>

@protocol ProcessNameDelegate <NSObject>
@required
- (void) processName: (NSString *)n;
@end

@interface Name : UITableViewController <UITextFieldDelegate>{

id <ProcessNameDelegate> delegate;
    UITextField *name_textField;
}

@property (retain) id delegate;
@property (nonatomic, retain) UITextField *name_textField;

- (void)pressComplete;

@end

and when pop back to previous controller, then will call the following method is ViewWillDisappear,

- (void)pressComplete {
    NSString *name = (NSString *)name_textField.text;
[[self delegate] processName:name];
}

This will set value to nameOfAlarm
Everything is fine, but when I do reload then this is not showing in

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

It is showing something like below if I do use nameOfAlarm in cell value or even just doing NSLog,

    <_UIStretchableImage: 0x14db10> //the first time in nameOfAlarm,

the second time If I will go in Name controller and do it, then will print as follows

<UILabel: 0x1cd6c0; frame = (13 0; 25 27); text = 'ON'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1d75f0>>

or like this

<UILabel: 0x179ed0; frame = (101 0; 32 27); text = 'OFF'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x179f40>>

I am not able to get the problem, because the same variable is working showing correct values in other methods, but not working well with

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

Why?

  • 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-25T10:27:21+00:00Added an answer on May 25, 2026 at 10:27 am

    In processName: you do this:

    nameOfAlarm = (NSString *)n;
    

    The cast is not necessary but it doesn’t hurt. The problem is that you are not retaining n and it can go away any minute leaving you with a dangling pointer. You need to do this:

    self.nameOfAlarm = n; // which is different from nameOfAlarm = n;
    

    The dot notation is just syntactic sugar for:

    [self setNameOfAlarm:n];
    

    Since the property is marked retain, the property setter that is created for you via synthesize will retain the new value of nameOfAlarm (n) and release the old value of nameOfAlarm.

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

Sidebar

Related Questions

I am making a UITableView by inheriting UITableViewControll as below @interface addAlarm : UITableViewController
I have created a controller class named TAddAlarmController which has a tableview which consists
I have an Activity communicating with and directly accessing a background Service's data members
I have a custom validation method that ensures an alarm can only be set
In my app I need to create an event in the Calendar programmatically, all
I have implemented event calendar application.In which I have added event data in iphone
I'm working on a project implementing a clock using PIC18, LCD, ... etc and
Context: I have a TableLayout (created using XML), which has one TableRow, which has
So I don't see where it is casting it into android.view.ViewGroup I get this
In my application Application_Exit event i am trying to set an alarm using the

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.