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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:46:30+00:00 2026-05-21T11:46:30+00:00

I am trying to access properties of an object (person’s firstName) which is stored

  • 0

I am trying to access properties of an object (person’s firstName) which is stored in an array and assign it to labels in a seperate view Controller (SplitMethodViewController). The name value is successfully assigned here. Code snippet as below:

In the initial view controller (before displaying the modal view controller containing the UILabel):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    int row = [indexPath row];
    Person *thisPerson = (Person *)[self.personArray objectAtIndex:row];

    SplitMethodViewController *smvc = [[SplitMethodViewController alloc]initWithNibName:nil bundle:nil];
    smvc.nameLabel.text = [[NSString alloc] initWithFormat:@"%@", thisPerson.firstName];

    //This lines returns the value I want, showing that assignment is working till this point
    NSLog(@"The name label is %@", smvc.nameLabel.text);

    [self presentModalViewController:smvc animated:YES];

    [smvc release];

}

However, the values became blank when I check in the splitMethodViewController (checked in ViewDidLoad Method)

@interface SplitMethodViewController : UIViewController 
{
    UILabel *nameLabel;
}

@property (nonatomic, retain) IBOutlet UILabel *nameLabel;
@end

@implementation SplitMethodViewController

@synthesize nameLabel;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    // Custom initialization.
    self.nameLabel = [[UILabel alloc] init];
    }
    return self;
}

- (id)init 
{
    return [self initWithNibName:nil bundle:nil];
}
- (void)viewDidLoad 
{
    //name label returning nothing here.
    NSLog(@"namelabel is %@",self.nameLabel.text);

    [super viewDidLoad];
}
@end

I am sure I made some silly mistake somewhere. I have tried deleting all the outlets and labels and re-created just one name label and outlet. But I am still hitting this same issue.

Any help will be appreciated!

  • 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-21T11:46:31+00:00Added an answer on May 21, 2026 at 11:46 am

    Did you actually allocate and instantiate the nameLabel and evenBillAmountLabel once you instantiate the SplitMethodViewController? In Objective-C messages (method calls) can be sent to nil (non-existant objects) without returning any errors, but also without any results.

    Make sure the -init method on SplitMethodViewController looks somewhat like this:

    // this is the designated initializer of most view controllers, 
    // do initialization here ...
    - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle 
    {
        self = [super initWithNibName:nibName bundle:nibBundle]; 
        if (self)
        {
            nameLabel = [[UILabel alloc] init];
            evenBillAmountLabel = [[UILabel alloc] init];
            // add other stuff you need to initialize ...
        }
        return self;
    }
    
    - (id)init 
    {
        // since we don't wanna re-implement allocation and instantiation for every 
        // initializer, we call the 'designated initializer' with some default values,
        // in this case the default nibName and bundle are nil.
        return [self initWithNibName:nil bundle:nil];
    }
    
    - (void)dealloc 
    {
        [nameLabel release];
        [evenBillAmountLabel release];
        [super dealloc];
    }
    

    Be sure to read about designated initializers if this is new to you and if this was related to your issue. Here’s a link to Apple’s documentation on the subject.

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

Sidebar

Related Questions

Hi I'm trying to access a WCF service which returns a JSON Array using
I have a simple view in which I am trying to access the Model
I am trying to access properties of a config object from within another object:
I'm trying to access properties of a transformable core data object like this: MainObject
Let's assume I have an array of object properties I'd like to access: $properties
I'm trying to access properties on the RootVisual object: [ScriptableType] public class ApplicationInfo {
In ActionScript3, I am trying to access the properties of the caller object from
I am trying to access/change the properties of a class' Parent through Reflection. If
Trying to access a Servlet from a button on HTML page //Html Page FORM
When trying to access the database, I am unable to access the column. I

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.