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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:40:08+00:00 2026-06-15T06:40:08+00:00

Is there something important I need in RoomItem to ensure that this method isn’t

  • 0

Is there something important I need in RoomItem to ensure that this method isn’t skipped? It’s the very first one in my detail view controller, and it is continually skipped when I’m in debugging mode. I’m sure I’m missing something ridiculously simple, but I’ve been staring at it for hours and just can’t figure out what it is.

@interface DetailViewController ()
- (void)configureView;
@end
@implementation DetailViewController
- (void)setDetailItem:(RoomItem *)newDetailItem
{
    if (_detailItem != newDetailItem) {
        _detailItem = newDetailItem;

        // Update the view.
        [self configureView];
    }
}
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem) {
    [_roomTxt setText:[_detailItem room]];
    [_buildingTxt setText:[_detailItem building]];
    [_dateTxt setText:[self dateCreatedString]];
    [_buildingImageView setImage:[_detailItem buildingImage]];
    _oi = [_detailItem objectIndex];
}
}

MasterViewController (root table view) methods that alloc and init new and existing detailViewControllers

- (void)insertNewObject:(id)sender
{
//add button invokes this
DetailViewController *ivc = [[DetailViewController alloc] init];
[self.navigationController pushViewController:ivc animated:YES];
NSLog(@"detailViewController allocated and initialized: %@", ivc);
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.detailViewController) {
    self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
    NSLog(@"detailViewController initialized: %@", self.detailViewController);
}
//navigates to detailViewController and passes it the item's data
self.detailViewController.detailItem = [[[RoomList sharedStore] getAllItems] objectAtIndex:[indexPath row]];
[self.navigationController pushViewController:self.detailViewController animated:YES];
}

Here is the tableView:didSelectRowAtIndexPath method that should be passing everything needed by the detail view controller, from the RoomList:sharedStore:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.detailViewController) {
    self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
}
//navigates to detailViewController and passes it the item's data
self.detailViewController.detailItem = [[[RoomList sharedStore] getAllItems] objectAtIndex:[indexPath row]];
[self.navigationController pushViewController:self.detailViewController animated:YES];
}

…and the RoomItem.m file:

- (void)awakeFromFetch
{
[super awakeFromFetch];

UIImage *pic = [UIImage imageWithData:[self buildingThumbnailData]];
[self setPrimitiveValue:pic forKey:@"buildingThumbnail"];
}
- (id)initWithRoom:(NSString *)room Building:(NSString *)building 
{
self = [super init];
if (self) {
    [self setRoom:room];
    [self setBuilding:building];
}
return self;
}

DetailViewController.h

#import <UIKit/UIKit.h>
@class RoomItem;
//pic edit: added delegates
@interface DetailViewController : UIViewController <UINavigationControllerDelegate,
UIImagePickerControllerDelegate, UITextFieldDelegate, UIPopoverControllerDelegate,
UIPageViewControllerDelegate>
{
__weak IBOutlet UITextField *roomField;
__weak IBOutlet UITextField *buildingField;
__weak IBOutlet UILabel *dateLabel;

UIPopoverController *imagePickerPopover;
}
@property (nonatomic, strong) RoomItem *detailItem;
@property (weak, nonatomic) IBOutlet UIButton *updateBtn;
@property (weak, nonatomic) IBOutlet UIButton *detailsBtn;
@property (weak, nonatomic) IBOutlet UITextField *roomTxt;
@property (weak, nonatomic) IBOutlet UITextField *buildingTxt;
@property (weak, nonatomic) IBOutlet UILabel *dateTxt;
@property (weak, nonatomic) IBOutlet UIImageView *buildingImageView;
@property (weak, nonatomic) UIImage *buildingImage;
@property (weak, nonatomic) NSNumber *oi;
- (IBAction)backgroundTapped:(id)sender;
- (IBAction)takePicture:(id)sender;
- (IBAction)updateRoomItem:(id)sender;
- (IBAction)goToReportDetails:(id)sender;
@end

Edit:here is a pseudo-UML diagram that illustrates what I’m seeing when I step through with the debugger (it reads from left to right, top to bottom):
enter image description here

  • 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-06-15T06:40:11+00:00Added an answer on June 15, 2026 at 6:40 am

    Alrighty, first things first. The reason -(void)setDetailItem:(RoomItem *)newDetailItem was being skipped is due to me not passing it the newly created RoomItem in the DVC. I was doing this initially, but mistakenly got rid of it while trying to correct the issue somewhere else.

    In DetailViewController.m:

    - (void)insertNewObject:(id)sender
    {
    RoomItem *newItem = [[RoomList sharedStore] createItem];
    
    DetailViewController *ivc = [[DetailViewController alloc] init];
    
    [ivc setDetailItem:newItem];
    
    [self.navigationController pushViewController:ivc animated:YES];
    NSLog(@"detailViewController allocated and initialized: %@", ivc);
    }
    

    Getting this to work though took some restructuring in the RoomList.m file. I had initially attempted to marry the create and update functions into one method. That doesn’t fly if I’m creating in the MVC, and updating in the DVC.

    So I split the two up:

    - (RoomItem *)createItem
    {
    double order;
    
    //create new roomItem
    //tracks what number item it's creating
    if ([allItems count] == 0) {
        order = 1.0;
    }
    else
    {
        order = [[[allItems lastObject] objectIndex] doubleValue] + 1;
    }
    NSLog(@"Adding after %d items, order = %.2f", [allItems count], order);
    
    RoomItem *p = [NSEntityDescription insertNewObjectForEntityForName:@"RoomItem"
                                                    inManagedObjectContext:context];
    
    [p setObjectIndex:[NSNumber numberWithDouble:order]];
    [p setDateCreated:[NSDate date]];
    [allItems addObject:p];
    
    [self saveChanges];
    
    return p;
    }
    - (RoomItem *)updateItemWithRoom:(NSString *)room Building:(NSString *)building ObjectIndex:(NSNumber *)objectIndex DateCreated:(NSDate *)dateCreated ImageKey:(NSString *)imageKey BuildingImage:(UIImage *)buildingImage BuildingThumbnail:(UIImage *)buildingThumbnail BuildingThumbnailData:(NSData *)buildingThumbnailData
    {
    NSError *error = nil;
    
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"RoomItem" inManagedObjectContext:context];
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:entity];
    
    int32_t oid = [objectIndex integerValue] - 1;
    NSLog(@"objectIndex = %d", oid);
    
    RoomItem *currentRoomItem = [[context executeFetchRequest:request error:&error] objectAtIndex:oid];
    
    //[currentRoomItem setItemEdited:YES];
    [currentRoomItem setRoom:room];
    [currentRoomItem setBuilding:building];
    [currentRoomItem setImageKey:imageKey];
    [currentRoomItem setBuildingImage:buildingImage];
    [currentRoomItem setBuildingThumbnail:buildingThumbnail];
    [currentRoomItem setBuildingThumbnailData:buildingThumbnailData];
    
    [self saveChanges];
    
    return currentRoomItem;
    }
    

    Lastly, the setDetailItem and configureView methods:

    - (void)setDetailItem:(RoomItem *)detailItem
    {
    if (_detailItem != detailItem) {
        _detailItem = detailItem;
        [self configureView];
    }
    }
    - (void)configureView
    {
    if (self.detailItem) {
        [_roomTxt setText:[_detailItem room]];
        [_buildingTxt setText:[_detailItem building]];
        [_dateTxt setText:[self dateCreatedString]];
        [_buildingImageView setImage:[_detailItem buildingImage]];
    }
    }
    

    This should serve as a lesson about taking the time to read the core data documentation, or any other for that matter…especially noobs like myself.

    Thanks again to emrys57 for the help.

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

Sidebar

Related Questions

Is there something in EF 4.1 that allows for a reconnect to a database
Is there something in the Android developer guidelines that disuades developers from providing the
Hey there guys, this is my first question on Stack Overflow. I figured this
There is probably a very simple answer to this, but I want to be
Is there something new about row-level security in SQL Server 2012? In 2008 and
Is there something equivalent to OmniCppComplete for java in vim ? I know of
Is there something akin to the .NET xsd.exe for java - generating classes from
Is there something like serialize/unserialize PHP functions in jQuery? These functions return a string
Is there something like die in JavaScript? I've tried with break, but doesn't work
Is there something like the following in Apache Common Lang or Spring Utils or

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.