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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:28:42+00:00 2026-05-22T21:28:42+00:00

I seem to be missing a key fundamental concept on sending data between two

  • 0

I seem to be missing a key fundamental concept on sending data between two classes. I read another post on here, and I’ll comment on that in a sec, but here is what I have. In a custom view class, I got a NSMutableDictionary that is working fine and is retained:

@interface myView : UIView {
}

@property (nonatomic, retain) NSMutableDictionary*myDictionary;

The methods in myView use myDictionary with no problem. For example, I can do this fine:

 NSArray*sorted=[[NSArray alloc] initWithArray:[self.myDictionary keysSortedByValueUsingSelector:@selector(compare:)]];

In my view controller, I am then trying to create a similar array using the same data in the myDictionary object from the custom class:

@interface myViewController : UIViewController {

}

@property (nonatomic, retain) IBOutlet myView * myView;

Then later I have:

  NSArray*sorted=[[NSArray alloc] initWithArray:[self.myView.myDictionary keysSortedByValueUsingSelector:@selector(compare:)]];

However, this myDictionary is always empty. It is not released anywhere in myView so it should still contain data. I’ve tried removing “self” with no luck.

Now, I read this similar post:

Data not sending between classes – Objective-C

Is this the only method for doing something like this? This implies that you must “send” the data from the source class to the receiving class. It suggests that you cannot have the receiving class “go fetch” the data from the source class as I am here. Is that right? More importantly, if that is the only method, then why so?

  • 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-22T21:28:42+00:00Added an answer on May 22, 2026 at 9:28 pm

    Triple-check your outlet connections! Then check them again.

    When you hook up an IBOutlet through Interface Builder, you have a real, instantiated object at the other end. You can access the properties of that object just as you would with any other object:

    self.myView.hidden = NO;
    

    If you assign a new object to that outlet:

    self.myView = [[MyCustomViewClass alloc] initWithFrame:someRect];
    

    you lose track of the view that was created for you in the xib, and when you try to access ivars of that new view:

    NSDictionary * aDict = self.myView.myDictionary;
    

    they will not have the same values as the ivars of the other view that is in the xib (they will probably be nil, in fact).

    It’s perfectly all right for data to be passed in either direction. You just need to have the appropriate references. The view can “send” to the controller, but it needs to have a reference to that controller set up:

    // Get a reference to view controller somehow
    self.myController = ...;
    [self.myController setArray:[self.myDictionary keys...]];
    

    Since controllers generally have references to their views, it probably makes more sense to go the other way, as you’re already doing.

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

Sidebar

Related Questions

I seem to be missing some key concept(s) when it comes to flex itemrenderers,
I seem to be missing something obvious here, why would I want more than
I seem to be missing something about LINQ. To me, it looks like it's
pdb and winpdb both seem to be missing this essential (to me) feature. I
I seem right now to be embroiled in a debate with another programmer on
I seem to always have problems with converting data to and from XML in
Simple situation - read a json file discover all key-value pairs compare key-value pairs
Am I missing something here? I follow the instructions exactly on this page (and
I can't seem to wrap my head around this, so I thought I'd post
I just moved a project to another server and seem to be having problems

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.