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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:59:14+00:00 2026-05-29T06:59:14+00:00

I have this managedContextObject I want to pass from a view controller to another.

  • 0

I have this managedContextObject I want to pass from a view controller to another. From a view controller called CatalogueViewController this works fine with no problem. And this is the no-problem code:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"AddItem"]) {

        UINavigationController *navigationController = segue.destinationViewController;
        DetailsItemViewController *detailsItemViewController = (DetailsItemViewController *) navigationController.topViewController;
        detailsItemViewController.delegate = self;
        detailsItemViewController.productToAdd = sender; //Mando il prodotto che ha provocato la segue (fatto manulamente sopra in didSelectRowAtIndexPath).
        detailsItemViewController.index = [prodotti.productsArray indexOfObject:sender];
        detailsItemViewController.managedObjectContext = self.managedObjectContext; //Gli passo anche l'oggetto per registrare i prodotti aggiunti in core data.
        NSLog(@"::::::::::::INDICE DELL'OGGETTO: %d", [prodotti.productsArray indexOfObject:sender]);

        //delegato, vado ad aggiungere i metodi delegati

    }
} 

And the line detailsItemViewController.managedObjectContext = self.managedObjectContext; has no problem.

BUT! When I try to pass SAME THING to THE SAME detailsItemViewController (the only difference is that I do that from another view controller called CartViewController) and this is the code:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"EditItem"]) {

        UINavigationController *navigationController = segue.destinationViewController;
        DetailsItemViewController *detailsItemViewController = (DetailsItemViewController *) navigationController.topViewController;
        detailsItemViewController.productToEdit = sender; //Mando il prodotto che ha provocato la segue (fatto manulamente sopra in didSelectRowAtIndexPath.
        detailsItemViewController.managedObjectContext = self.managedObjectContext; //Gli passo anche l'oggetto per registrare i prodotti aggiunti in core data.

        //Mi metto in ascolto di una notifica tramite il Notification Center.
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(objectEditedFromDetailsViewController:)
                                                     name:@"ObjectEdited"
                                                   object:nil];

    }
}

on the line: detailsItemViewController.managedObjectContext = self.managedObjectContext; Xcode is giving me this error message:

[…]CartViewController.m: error: Semantic Issue: Property ‘managedObjectContext’ not found on object of type ‘DetailsItemViewController *’

that obviously is not true!

WHY?!

Just to be clearer:

I make the #import of DetailsItemViewController.h in CartViewController:

#import "CartViewController.h"
#import "Product.h"
#import "CartCell.h"
#import "CDProduct.h"
#import "DetailsItemViewController.h"
#import "UIImage+Resize.h"


@implementation CartViewController {

All the lines but detailsItemViewController.managedObjectContext = self.managedObjectContext; work. All this lines work with no problem at all:

UINavigationController *navigationController = segue.destinationViewController; // <---- WORKS
DetailsItemViewController *detailsItemViewController = (DetailsItemViewController *) navigationController.topViewController; // <---- WORKS
detailsItemViewController.productToEdit = sender; // <---- WORKS

In fact, for example, if I try to pick up another detailsItemViewController’s property it works well! Only if I do
detailsItemViewController.managedObjectContext = self.managedObjectContext; I get the error from Xcode.

And here the DetailsItemViewController.h

#import <UIKit/UIKit.h>
#import "Product.h"
#import "ProductDetails.h"
#import "CDProduct.h"


//Delegato per lo screen successivo di aggiunta roba nel carrello.
@class DetailsItemViewController;
@class CatalogueItem;

@protocol DetailsItemViewControllerDelegate <NSObject>

- (void)detailsViewControllerDidCancel:(DetailsItemViewController *)controller;
- (void)detailsViewControllerDidDone:(DetailsItemViewController *)controller didFinishAddingItem:(CatalogueItem *)item;

@end


//@class Product;
//@class ProductDetails;

@interface DetailsItemViewController : UIViewController <NSURLConnectionDelegate>

@property (nonatomic, weak) id <DetailsItemViewControllerDelegate> delegate;

@property (nonatomic, strong) Product *productToAdd;    //Li differenzio così capisco quello che devo fare. NB: per chi legge questo codice:productToAdd non indica un oggetto da aggiungere ma un oggetto a cui si può modificare la quantità per aggiungerlo al carrello.
@property (nonatomic, strong) CDProduct *productToEdit;

@property (nonatomic, strong) ProductDetails *productToShow; //Qui ci metto il prodotto che ricavo da loadProducts.

@property (strong, nonatomic) IBOutlet UIImageView *graphicImage;
@property (strong, nonatomic) IBOutlet UIImageView *overviewImage;
@property (strong, nonatomic) IBOutlet UIStepper *stepper;
@property (strong, nonatomic) IBOutlet UILabel *stepperValueLabel;
@property (strong, nonatomic) IBOutlet UILabel *productNameLabel;
@property (strong, nonatomic) IBOutlet UILabel *priceLabel; //Il prezzo poi lo prendo facendo il parsing di un altra pagina.
@property (strong, nonatomic) IBOutlet UILabel *totalPrice;

@property (nonatomic, assign) int index;    //In questa property ci metto l'indice dell'oggetto passato (productToAdd) in modo sapere che articolo dell'XML parsare.

@property (nonatomic, strong) NSMutableData *receivedData;

@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext; //Per registrare i prodotti in core data.


- (IBAction)cancel;
- (IBAction)done;
- (IBAction)changeValue:(UIStepper *)sender;

@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-29T06:59:15+00:00Added an answer on May 29, 2026 at 6:59 am

    Just solved the problem!
    Well this wasn’t a simple one. It happened that few days earlier i had to redo the project (because i have accidentally erased the Storyboard), and so i added some classes from the old to the new same named project. The problem is that Xcode shuffles all the classes in different folder so i had some copied class in the new project folder and other older class in subfolder. This cause me to have class with the same name here and there but with different code. So, EVEN if in the Xcode IDE i had the new detailsViewController WITH managedContextObject, the CartViewController was referring to an old version of detailsViewController that has not the managedContextObject property (but has all the other property because i have created them before the mess with the storyboard).
    So if you want to copy some older class in your project pay a lot of attention in what you are doing.

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

Sidebar

Related Questions

I have this code in jQuery, that I want to reimplement with the prototype
I have this code to send variables to a datagrid on another page protected
I have this treepanel and i want to call this.getId() method of mainpaneltree from
I have this piece of code i want to synchronized between the StartWatch() and
I have this idea for a free backup application. The largest problem I need
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
Have this dictionay retrieving values from DataTable: Dictionary<string,string> meta= ds.Tables[1].Select(key<>'format').AsEnumerable().ToDictionary(k=>k.Field<string>(0),v=>v.Field<string>(1)); How would I apply
Have have this line of code in my form when I create a new
I have this classic problem that seems impossible to solve for me. I just
I have this menu example But in this example new activity is not called,

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.