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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:09:51+00:00 2026-06-04T04:09:51+00:00

I am trying to do an ios app but I am stuck at passing

  • 0

I am trying to do an ios app but I am stuck at passing data between classes .
This is my second app . The first one was done whit a global class , but now I need
multiple classes . I tried many tutorials , but did not work or the passed value was always zero . Can someone please write me a simple app to demonstrate passing of variables in IOS 5 .
Nothing special , storyboard whith 2 view controllers , one variable .

Thank you for your help .

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.

            FirstViewController *fv;
            fv.value = indexPath.row;

            NSLog(@"The current %d", fv.value);

            FirstViewController *detail =[self.storyboard instantiateViewControllerWithIdentifier:@"Detail"];
            [self.navigationController pushViewController:detail animated:YES]; 

}

here is the code from my main view and i need to send the indexPath.row or the index of the cell that i pressed to the next view

  • 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-06-04T04:09:53+00:00Added an answer on June 4, 2026 at 4:09 am

    There are several things to do. Depending on the app, you could either add a variable to the AppDelegate class, making it availible to all classes through a shared instance. The most common thing (I think) is to make a singleton. For that to work, you can make a class, say StoreVars, and a static method that returns the object, which makes the class “global”. Within the method, you initialize all your variables, like you always would. Then you can always reach them from wherever.

    @interface StoreVars : NSObject
    
    @property (nonatomic) NSArray * mySharedArray;
    + (StoreVars*) sharedInstance;
    
    @implementation StoreVars
    @synthesize mySharedArray;
    
    + (StoreVars*) sharedInstance {
        static StoreVars *myInstance = nil;
        if (myInstance == nil) {
            myInstance = [[[self class] alloc] init];
            myInstance.mySharedArray = [NSArray arrayWithObject:@"Test"];
        }
        return myInstance;
    }
    

    This will make a singleton. If you remember to import “StoreVars.h” in your two viewControllers, you can access the now shared array like this;

    [StoreVars sharedInstance].mySharedArray;
                   ^
    

    This is a method returning a StoreVars object. Within the StoreVars class, you can implement any object and initialize it in the static method. Just always remember to initialize it, or else, all your object will be 0/nil.

    If you are not a fan of the UINavigationController and would rather use segues, it’s a lot easier, but can make your app rather “messy” imo. There is a method implemented in UIViewController you should overload:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        // Make sure your segue name in storyboard is the same as this line
        if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
        {
            // Get reference to the destination view controller
            YourViewController *vc = [segue destinationViewController];
    
            // Pass any objects to the view controller here, like...
            [vc setMyObjectHere:object];
        }
    }
    

    source: How to pass prepareForSegue: an object

    Do some research before asking questions like this. Read some tutorials, and try out yourself, and then ask questions related to what you are really looking for. It’s not everyday people want to do all the work for you, but sometimes you’re lucky. Like today.

    Cheers.

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

Sidebar

Related Questions

I am trying to build a image capture for my iOS app, but I
I'm trying to POST data from an iOS app to Node.js/Express. I cannot get
Hello I'm trying to archive an iOS app. I get this: warning: Application failed
I'm trying to access YouTube from within an iOS app, but the iOS SDK
I'm trying to port an iOS App to OSX and there is one thing
iOS beginner here. I'm trying to build the Facebook Demo App but I keep
I am trying to connect my iOS app to a GET data from my
I am trying to develop a collapsable/accordion like feature in my iOS app. This
I'm trying to learn iOS (4.3) programming and got stuck on this. I'm using
Trying to create a starter app with PhoneGap. I'm stuck on this line: navigator.device.capture.captureAudio(onSuccess,

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.