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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:02:18+00:00 2026-05-18T05:02:18+00:00

Ok, so I’m a relative noob with Objective-C/iOS programming, so hopefully someone with more

  • 0

Ok, so I’m a relative noob with Objective-C/iOS programming, so hopefully someone with more knowledge here can help me out.
I have an iPad application using the SplitViewController template (with Core Data). I created another UIViewController (with xib file) called PlayerViewController. This View has several UILabel components on it.

I have a list of players that show up in the RootViewController (UITableView) and when you select a player, I programmatically create a PlayerViewController (in DetailViewController), pass it the NSManagedObject that was passed to the DetailViewController, try to set the text of one of the labels on the PlayerViewController’s view, and then add it as a subview to the DetailViewController.

All of this works great except for the setting the text of the label on the PlayerViewController’s view. I’m not sure what I’m doing wrong. I have used NSLog to confirm that the NSManagedObject is not nil and that the NSManagedObject property I’m trying to use has the correct text.

I’m at a loss here. Any help would be greatly appreciated. (Code follows):

This method is in the DetailViewController.m file:

- (void)configureView {
    // Update the user interface for the detail item.
    PlayerViewController *player = [[PlayerViewController alloc] init];
    player.player = detailItem;
    [self.view addSubview:player.view];
}

This method is called when the user selects an item from the RootViewController (This functionality, calling of configureView, is setup by the template and I haven’t changed it).

Setting the player property of the PlayerViewController to object detailItem is handled in the setPlayer method of that class.

- (void)setPlayer:(NSManagedObject *)managedObject {

    if (player != managedObject) {
        [player release];
        player = [managedObject retain];

        // Update the view.
        [self configureView];
    }
}

I then have a configureView method as well in PlayerViewController that sets the text of the label:

- (void)configureView {
    nickName.text = [[player valueForKey:@"Nickname"] description];
    NSLog(@"Nickname %@", [[player valueForKey:@"Nickname"] description]);
    NSLog(@"Nickname %@", nickName.text);
}   

Ok, so the first NSLog statement prints the desired value, but the text of the UILabel (called nickName) returns nil.

The following is the full PlayerViewController.h & .m files:

PlayerViewController.h:

#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>


@interface PlayerViewController : UIViewController {

    NSManagedObject *player;

    IBOutlet UILabel *nickName;
    IBOutlet UILabel *goalCount;
    IBOutlet UILabel *assistCount;
    IBOutlet UILabel *timeInGame;
}

@property (nonatomic, retain) IBOutlet UILabel *nickName;
@property (nonatomic, retain) IBOutlet UILabel *goalCount;
@property (nonatomic, retain) IBOutlet UILabel *assistCount;
@property (nonatomic, retain) IBOutlet UILabel *timeInGame;

@property (nonatomic, retain) NSManagedObject *player;

@end

PlayerViewController.m:

#import "PlayerViewController.h"


@implementation PlayerViewController

@synthesize nickName, goalCount, assistCount, timeInGame, player;

#pragma mark -
#pragma mark Managing the detail item

/*
 When setting the player item, update the view 
 */
- (void)setPlayer:(NSManagedObject *)managedObject {

    if (player != managedObject) {
        [player release];
        player = [managedObject retain];

        // Update the view.
        [self configureView];
    }
}       

- (void)configureView {
    nickName.text = [[player valueForKey:@"Nickname"] description];
    NSLog(@"Nickname %@", [[player valueForKey:@"Nickname"] description]);
    NSLog(@"Nickname %@", nickName.text);
}

/*
 // 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 {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


- (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 {
    [super dealloc];
}


@end

I’m sure I’m just missing something trivial, but I can’t figure it out, and haven’t been able to find any answers searching the web.

Thanks for any help!

  • 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-18T05:02:18+00:00Added an answer on May 18, 2026 at 5:02 am

    Ok, so after playing with this for a bit and searching and searching around, I have gotten the answer to my problem. It turns out all the code I had was fine except the location of one statement. My call to configureView in PlayerViewController.m needed to be in viewDidLoad() not in the setPlayer() method. It all works great now.

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

Sidebar

Related Questions

No related questions found

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.