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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:21:03+00:00 2026-05-23T12:21:03+00:00

I have created NSMutale Array in HeroListViewController . I want use it in another

  • 0

I have created NSMutale Array in “HeroListViewController”. I want use it in another viewController which is MapTutorialViewController. I tried like this.

in HeroListViewController.h

MapTutorialViewController *maptutorialcontroller;
NSMutableArray *listData; 

set properties and synthesize them correctly

in HeroListViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];

    listData = [[NSMutableArray alloc] init];   
    }

 - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *HeroTableViewCell = @"HeroTableViewCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:HeroTableViewCell];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:HeroTableViewCell] autorelease];
}
NSManagedObject *oneHero = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSInteger tab = [tabBar.items indexOfObject:tabBar.selectedItem];
switch (tab) {
    case kByName:
        cell.textLabel.text = [oneHero valueForKey:@"name"];
        cell.detailTextLabel.text = [oneHero valueForKey:@"secretIdentity"];
        break;
    case kBySecretIdentity:
        cell.detailTextLabel.text = [oneHero valueForKey:@"name"];
        cell.textLabel.text = [oneHero valueForKey:@"secretIdentity"];
    default:
        break;
}

        [listData addObject: [oneHero valueForKey:@"secretIdentity"]];


        count=[listData count];
                printf("No of items of listData:%u\n", count);


if(maptutorialcontroller==nil){
      maptutorialcontroller= [[MapTutorialViewController    alloc]initWithNibName:@"MapTutorialViewController" bundle:nil];
maptutorialcontroller.secondarray=listData;
}
count=[maptutorialcontroller.secondarray count];
printf("No of items of seconarray :%u\n", count);

return cell;

}

OUTPUTS : No of items of listData:3
No of items of seconarray :3 // both are correct

BUT the the problem I have, when I try to use the secondarray in “MapTutorialViewController” like this,
in MapTutorialViewController.h

    HeroListViewController *heroviewcontroller;
  NSMutableArray *secondarray; 

set properties and synthesize them correctly

in MapTutorialViewController.m

 - (void)viewDidLoad 
   {
    heroviewcontroller = [[HeroListViewController alloc]initWithNibName:@"HeroListViewController"  bundle:nil]; 
   self.secondarray=[heroviewcontroller.listData mutableCopy];
   //secondarray= heroviewcontroller.listData;
int count;
count = [secondarray count];
//  
   printf("No of items of secondarray from MapTutorialViewContriller :%u\n", count);
   }

OUTPUT : No of items of secondarray from MapTutorialViewContriller :0
Why it is 0

whats the wrong with my code, please help me

  • 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-23T12:21:04+00:00Added an answer on May 23, 2026 at 12:21 pm

    Example

    firstviewcontroller .h file
    
            before @interface 
    
            use @class secondViewcontroller;
    
    
    declare this inside of @interface  with
    
            secondViewcontroller *sVC;
    
    
    then in firstViewController.m file 
    
            before @implementation          
    
        #import "secondViewcontroller.h"
    
    then
    -------------------
    
    secondVC.h file
    
            @interface inside declare this
    
            say NSMutableArray *secondarray;
    
            and sythasize them.
    
    ------------------- 
    
    after this 
    
            in firstViewcontroller.h viewdidload create this sVC by alloc and initwithnibname then
    
            sVC.secondArray=urfirstArray;
    
            now while u push this sVC controller to navigation controller u can nslog this array in viewdidload.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that gets created from JSON. The array looks like this:
In my Iphone App I have created this query: SELECT * FROM visuel where
I have created a scrollview, and some button are placed on this scrollview. And
I have created an array inside a for loop and I am not able
I have created an app which has a library of images. I have imported
I have created an app which is approved by apple and currently buyable in
Hai, I have created a tab based iRestaura project. I use 5 tab bar
I have created a controller class named TAddAlarmController which has a tableview which consists
I have created an animation like [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile: @Actor.plist]; spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@Actor.pvr.ccz];
Have created a c++ implementation of the Hough transform for detecting lines in images.

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.