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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:16:36+00:00 2026-05-28T13:16:36+00:00

i have a DetailViewController and a Messages class(this is a TableViewController class). I parse

  • 0

i have a DetailViewController and a Messages class(this is a TableViewController class). I parse some web information in the first class and want to use some values amongst them in the second class. As i looked arround in here and google for a few haurs and by now i think i need to define some extern variables in my second class and initialize them with the objects of the first class.. I tried a few ways but all failed.

In my first clas i have an NSMutableArray variable called messID, in the second class i do this:

#import DetailViewController
.
.
 extern NSMutableArray *myArray;
 DetailViewController *myObject;
myArray=myObject.messID;

But i got the error below:

Undefined symbols for architecture i386:
  "_myArray", referenced from:
      -[messages tableView:cellForRowAtIndexPath:] in messages.o

What am i doing wrong and what can i do please can any one help?..

EDIT
I’ve imported needed class,
in the .h file of second class i use this:

@interface messages : UITableViewController{

       BNT_1DetailViewController *myObject;
}
@property(retain, nonatomic)BNT_1DetailViewController *myObject;

And its .m file is:

…

@sysnthesize myObject;


     viewDidLoad{
     myObject=[[BNT_1DetailViewController alloc]init];}
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    #warning Incomplete method implementation.
        // Return the number of rows in the section.
        return myObject.mesID.count;
        }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
        //extern NSMutableArray *messID;


        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }NSLog(@" -> %@",myObject.mesID );
           cell.textLabel.text= [myObject.mesID objectAtIndex:indexPath.row];    
            // Configure the cell...
       // [tableView reloadData]; 
        return cell;

        }
  • 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-28T13:16:37+00:00Added an answer on May 28, 2026 at 1:16 pm

    I would not use extern for what you are trying to do, which means you are also defining some global variables (and trying to access them from the files where you use the extern keyword). For the records, anyway, the error you are getting depends on the fact that extern is just a directive that does not define your objects — it simply declares them as defined elsewhere. So you should add in some .m file the proper definition for your objects, without forgetting to also initialize them at some point in time so that they point to meaningful objects.

    A better way to do what you are trying to do is through public properties declared in your first class allowing access to the NSMutableArray from the second class.

    An example of this could be:

    @interface DetailViewController : ... {
    
        NSMutableArray* array;
    }
    @property (...) NSMutableArray* array;
    @end
    
    @interface Messages : ... {
        DetailViewController* detailViewController;
    }
    ...
    @end
    
    @implementation Messages;
    ...
    ... detailViewController.array...
    ...
    @end
    

    This solution is better because it does not use global variables and has a better encapsulation.

    Actually, you could try and define a Model (like in model-view-controller) which contains all of your data and have them shared among all the controllers that need it. This would be an better approach.

    EDIT: on how to connect one controller to another…

    Say that at some point you create a new controller:

     messageDetail *detailViewController = [[messageDetail alloc] initWithNibName:@"messageDetail" bundle:nil];
    

    Now, detailViewController needs retrieving its data from messages, which is by the way the controller which is creating it. You have several options for doing that. An easy one is having a public property in messageDetail that links to messages:

        @interface messageDetail : ... {
            ....
        }
        @property (nonatomic, retain) messages* messagesRef;
        ...
        @end
    

    (don’t forget to synthesize this property in messageDetail implementation).

    Then, when you instantiate messageDetail, you simply do this:

     messageDetail *detailViewController = [[messageDetail alloc] initWithNibName:@"messageDetail" bundle:nil];
     detailViewController.messagesRef = self;
    

    Once you do this, your detailViewController will have a pointer, correctly initialized, to point to the other controller.

    If your other controller exposes (like I explained above) a property with the NSArray, your are done.

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

Sidebar

Related Questions

I have splitViewController which has as MasterViewController some viewController and as DetailViewController some tableViewController.
I have implemented a UISegmentControl as the rightBarButton of my detailViewController. This view controller
In my DetailViewController i have the code UPDATED x2 This is my setEditing -
I have a tableView that's loosely based on the DetailViewController in ye olde SQLiteBooks.
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have a n-tire web application and search often times out after 30 secs. How
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have had to write my first proper multithreaded coded recently, and realised just how
I have a RootViewController and a DetailViewController where I am trying to pass a
I have a UITableView with many rows that push a DetailViewController depending on the

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.