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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:43:05+00:00 2026-05-16T18:43:05+00:00

recently I joined two Xcode projects together. To get this thing to work, I

  • 0

recently I joined two Xcode projects together. To get this thing to work, I had to alloc and initialize my view controller.

self.myViewController = [[MyViewController alloc] init];

But why? In the other project I have the same code. The sole difference is hierarchy of the different views. I added a new view to the top (beginning). So the calling View Controller is not the first view on the stack anymore.

I’m pushing my view in this way on the stack:

[[self navigationController] pushViewController:myViewController animated:YES];

In my NIBs I have added a View Controller object with IB and connected the Outlets.

And I have a memory management question too: If I have a property like myViewController, do I have to release it? The “normal” release is done in the dealloc method. But do I have to use an additional release because of the alloc? I don’t think so, but I ask you anyway.

  • 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-16T18:43:06+00:00Added an answer on May 16, 2026 at 6:43 pm

    I would need to see more code to answer why you had to alloc your view controller, but I’d say that you always alloc them manually (at least in my experience).

    As for the memory management question, if your property is declared as a retain property (@property(retain) UIViewController *myViewController), you are indeed leaking memory, since the retain count after alloc will be 1, and after the retain done by your accessor will be 2. Hence, if you release it only once, you’ll end up with a leak.

    I usually do this instead:

    self.myViewController = [[[MyViewController alloc] init] autorelease];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently joined this organisation that I am currently working at that has asked
just joined this awesome site… Ive recently been working in XNA on C#, making
I recently joined a new team. This team has been using Subversion for their
I have recently joined a project that is using multiple different projects. A lot
I've recently joined a company which has had a number of developers of varying
Recently I'm trying to get a hang on how bootloaders work. I'm writing my
I recently joined a company which is using django to build their product. I'm
I recently joined the IT department of a big insurance company. Although the department's
I'm reviewing some code on the project I recently joined, and in a C#
I've recently joined TopCoder and have been practicing in the Practice Rooms for 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.