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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:07:11+00:00 2026-05-26T18:07:11+00:00

I am trying to set up an object to control all of my data

  • 0

I am trying to set up an object to control all of my data so it can set things up in the background to it appears my tableviews load faster than they do now etc.

This is what I am trying to achieve.

enter image description here

I am setting a variable in the NSObject from the secondVC when the tableviewcell is selected like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Access selected cells content (cell.textLabel.text)
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    //Parent view logic (sends info back to the correct cell in parent view)
    if (parentViewSelectedIndexPath.section == 0) 
    {
        if (parentViewSelectedIndexPath.row == 0) 
        {
            //Predicates restrict the values that will be returned from the query
            NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"MANUFACTURER",cell.textLabel.text];
            NSArray *filterArray = [myDataArray filteredArrayUsingPredicate:predicate];
            //[[self delegate] setManufactureSearchFields:filterArray withIndexPath:indexPath]; //This is where I pass the value back to the mainview
            //Using Object
            VehicleControllerNSObject *vehicleControllerNSObject = [[VehicleControllerNSObject alloc] init];
            [vehicleControllerNSObject setFirstCell:filterArray];

        }
//etc

At the end there you can see the method that is getting set up in the VechicleControllerNSObject which looks like this.

-(void)setFirstCell:(NSArray *)array{

    manufactureSearchObjectStringFVC = [[array valueForKey:@"MANUFACTURER"] objectAtIndex:0];
    NSLog(@"%@", manufactureSearchObjectStringFVC); // this prints the correct value to the console
}

As you can see this prints the correct output fine.

however I have no idea how to call manufactureSearchObjectStringFVC and pass the value it holds into the uitableviewcell that I would like to pass it in on my firstviewcontroller.

This is what I have for testing atm.

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    VehicleControllerNSObject *vehicleControllerNSObject = [[VehicleControllerNSObject alloc] init];
    manufactureSearchObjectString = vehicleControllerNSObject.manufactureSearchObjectStringFVC;
    NSLog(@"%@", vehicleControllerNSObject.manufactureSearchObjectStringFVC);

}

That nslog prints null..

I have three questions

1, how do I get the correct value into the first valuecontroller.

2, should I be using viewDidAppear like this?.. I think not.. how can I do this better

3, Do you think this is a good way of doing this type of thing, as in the future i would like to use the NSObjectClass to parse info, cache etc all behind the senses leaving the views to just display when the data is ready hopefully helping performance..

Any help would be hugely appreciated as I really want to learn this stuff as i know its important for me to know.

  • 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-26T18:07:12+00:00Added an answer on May 26, 2026 at 6:07 pm

    Your question is so beautifully and clearly formatted and diagrammed that it seems a shame to ask you to do a search. But here it is:

    Search for Sharing Data between View Controllers

    You’ll find many good discussions about sharing data between view controllers.

    Briefly, though, I can tell you why your code isn’t working. In your tableView:didSelectRowAtIndexPath: method, you are creating (alloc/init) a new instance of your VehicleControllerNSObject class each time. Then back in your first view controller on viewDidAppear:, again you are creating (alloc/init) a whole new instance each time.

    So you have multiple objects coming and going and they have nothing to do with each other. It’s a bit like giving some important information to one person at a bus station and then later randomly picking some other person out and trying to retrieve that same information from her.

    So one quick idea would be to create just once instance of your VehicleControllerNSObject (just an aside, that’s a bit of a strange name for a class since generally all objective-c objects are descendants of NSObject anyway. I’m just going to call that VehicleController for now)

    So let’s say you wanted a ‘sharedInstance’ of VehicleController. You could add a class method to VehicleController to give you a way to easily get that one sharedInstance:

    +(VehicleController*)sharedInstance {
    
        static VehicleController *sharedInstance_ = nil;
    
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
    
            sharedInstance_ = [[VehicleController alloc] init];
        });
    
        return sharedInstance_;
    }
    

    So to get that instance in methods in other classes you can just do something like :

    VehicleController *sharedController = [VehicleController sharedInstance];
    sharedController.someProperty = someValue;
    
    // and then back in your first view controller, similarly:
    VehicleController *sharedController = [VehicleController sharedInstance];
    id someValue = sharedController.someProperty;
    

    Again, check the search, many people have had good discussions on this. This is just one approach. I hope it at least makes sense why your code wasn’t working.

    Hope that helps.

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

Sidebar

Related Questions

I am trying to set a colour of an ellipse object in code behind.
I'm trying to set the CSS style of an object with the following: document.getElementById(obj).style='font-weight:bold;
I am trying to set my user agent string in the HttpClient apache object
We are trying to get tinyMCE object from DOM in order to set the
I'm trying to create a custom object that behaves properly in set operations. I've
I've been trying to read and set the departmentNumber property for a DirectoryEntry object
Im trying to figure out how to set the minimum someone can zoom out.
I am trying to make a control that can hold a variable amount of
I am trying to design a set of data controls that contain their own
I am trying to bind Asp.Net Repeater Control for Ajax Data using DataTables Plugin

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.