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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:24:11+00:00 2026-05-27T16:24:11+00:00

In this code I’m attempting to pass an array from one tab view to

  • 0

In this code I’m attempting to pass an array from one tab view to another using protocols. The method itself is a simple get method with one line returning an a mutableArray. Within it’s own class it works, within this class it is not even called.

- (void)viewDidLoad
{
    [super viewDidLoad];
    myLocationEntityArray = [[NSMutableArray alloc] initWithArray:[[self delegate] getMyLocationEntityArray]];
}

The header file for the class receiving the data:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@protocol CoreDataDelegate;

@interface ListTableViewController : UITableViewController
{
    NSManagedObjectContext *managedObjectContext;
    NSMutableArray *myLocationEntityArray;

    id <CoreDataDelegate> delegate;
}

- (NSMutableArray *)fetchCoreData;

@property(nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@property(nonatomic, assign) id <CoreDataDelegate> delegate;
@property(nonatomic, retain) NSMutableArray *myLocationEntityArray;

@end

@protocol CoreDataDelegate

//- (NSMutableArray *) fetchCoreData;
- (NSMutableArray *) getMyLocationEntityArray;

@end

The top of the header file sending the data:

@interface MapViewController : UIViewController <CLLocationManagerDelegate, CoreDataDelegate>
  • 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-27T16:24:12+00:00Added an answer on May 27, 2026 at 4:24 pm

    First you should change your procotol like this :

    @protocol CoreDataDelegate
    
    //- (NSMutableArray *) fetchCoreData;
    - (void) getMyLocationEntityArray:(NSMutableArray *)entityArray;
    
    @end
    

    You set your MapViewController to responds to your protocol CoreDateDelegate. So, I suppose you alloc your ListTableViewController inside the MapViewController. If that is the case, you need to do this :

    // MapViewController.m
    ...
    ListTableViewController *listVC = [[ListTableViewController alloc] init];
    listVC.delegate = self;
    // display your listVC
    ...
    
    // Somewhere in your code of MapViewController.m
    - (void) getMyLocationEntityArray:(NSMutableArray *)entityArray {
       // do something with entityArray
    }
    

    EDIT

    Following your comments, here is a simpler way to do what you want. NSNotification. It does not require protocol, and is easier to implement.

    // In ListTableViewController.m
    // In Init or viewDidLoad function
    
    
       [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(getEntity:) 
                                                     name:@"GetEntity"
                                                   object:nil];
    
    - (void)getEntity:(NSNotification *)notif {
       NSArray *entityArray = (NSArray *)[notif object];
       // do something with entityArray
    }
    
    // In dealloc or viewDidUnLoad function
       [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                     name:@"GetEntity"
                                                   object:nil];
    
    
    // In MapViewController.m
    // theEntityArray to be defined
        [[NSNotificationCenter defaultCenter] postNotificationName:@"GetEntity"
                                                             object:theEntityArray 
                                                           userInfo:nil];
    

    In few words, when you will post the GetEntity notification in MapViewController, it will call undirectly the -(void)getEntity: function of ListTableViewController

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

Sidebar

Related Questions

This code is from Prototype.js . I've looked at probably 20 different tutorials, and
This code is reading from mysql db tables and should return few names. But
This code can be used to select the first ten records from a table
This code involves a recursive Stored Procedure call and a not so great method
This code works properly in my localhost. I am using xampp 1.7.3. but when
this code using an OLEDB source will populate the OutputColumnCollection below it, the code
This code fails when I try to debug it using VC2010: char frd[32]=word-list.txt; FILE
This code example is from the APE official website: http://www.ape-project.org/ var client = new
This code is C/C++ and runs without warnings or debug messages. I'm using Code::blocks
This code in JS gives me a popup saying i think null is a

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.