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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:30:11+00:00 2026-05-25T10:30:11+00:00

I have an app and on the first page is a button that the

  • 0

I have an app and on the first page is a button that the user can set an image which is on the second page.
To switch pages, the code im using is:

- (IBAction)myCart:(id)sender; {
MyCartViewController * cart2 = [[MyCartViewController alloc]init];
cart2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:cart2 animated:YES];
[cart2 release];

}

And i also have another method this allows the user to press a button and set an image.

- (IBAction)outlet1 {
cart.displayImage = YES; 

}

cart is a ivar created in the .h file so i can use it through out the whole file. My problem is that i need to be able to use cart (not cart2) in the myCart method. How can i do this? Because if i try to swtich the cart2’s with just cart and i delete the line:
MyCartViewController * cart2 = [[MyCartViewController alloc]init];

the app crashes when i try to switch pages. How can i use the same variable for both methods? Thanks everybody!

  • 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-25T10:30:11+00:00Added an answer on May 25, 2026 at 10:30 am
    - (IBAction)myCart:(id)sender {
         MyCartViewController * cart2 = [[MyCartViewController alloc]init];
         cart2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
         [self presentModalViewController:cart2 animated:YES];
          [cart2 release];
    }
    

    cart2 is local reference variable and can not persist beyond the method myCart. Instead declare it as a part of interface variable and initialize it in the init method. Don’t forget to release it finally at the end where you are releasing all interface member variables ( in dealloc).

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

Sidebar

Related Questions

i have a problem with a WP7 app. I want that a user can
I have a app with a main viewcontroller that loads a first page viewcontroller.
I have an app with a UITextField, amongst other things. When the user first
I have a web app that is heavily loaded in javascript and css. First
I have written an app in C which expects two lines at input. First
For example: First, say I have a Silverlight app with Windowless=true so that I
I have a bunch of Seam form pages; each has a command button that
i have an application in which i have 2 pages.one page is Register page
In my app I have an advanced search page which uses a tableview with
I have an app that has a lot of activities. In the Settings page

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.