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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:40:25+00:00 2026-06-09T19:40:25+00:00

I need some help with releasing a controller in xcode ..im not using ARC

  • 0

I need some help with releasing a controller in xcode ..im not using ARC ..take a look at this simple code from my main delegate controller:

LoginViewController *login = [[LoginViewController alloc] init];
[window addSubview:login.view];
[window makeKeyAndVisible];
[login release];  // code runs if i comment out this line

If i comment out the last line the program runs.
The program crashes on the last line …i put in a zombie and here is the result:
2012-08-17 09:43:02.193 dialer[238:707] * -[LoginViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0x186360

how can i trace this and why is this even happing since im allocating and releasing right away. Does it have something to do with retain , etc

  • 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-09T19:40:26+00:00Added an answer on June 9, 2026 at 7:40 pm

    The login controller is added as a subview and then released, but the addSubview method doesn’t retain the controller (only the controller.view), so it can’t be used any further.

    You have to release it or you will have a leak, the solution is creating a property/ivar in your class and assigning the view controller to it (instead of a local variable), then release it in dealloc.

    I think the point you are missing is that the [login release] statement effectively reduces the retain count of your loginViewController to zero, and the object is lost/cleaned up, which is not what you want because you still need it as long as your subview is displayed.

    So your parent object (main controller, if I understand your example correctly) creates the loginController, adds the loginView as a subview (this is retained by doing the addSubview call), and then releases the controller, but you still need it to handle the login view! So the solution is to keep a reference in the main controller in order to retain it as long as needed (until you remove the loginView, or the main controller gets deallocated)

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

Sidebar

Related Questions

need some help with retrieving information+Profile pic from twitter using php , i wanted
Need some help to solve this. I have a gridview and inside the gridview
Need some help with this problem in implementing with XSLT, I had already implemented
Need some help gathering thoughts on this issue. Our team is moving ahead with
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help designing a bash script for grepping IP addresses from auth.log and
I need some help figuring this out. I am trying to create a function
I have some code which I need to lock using a semaphore or mutex.
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via
Need some help with Activerecord Querying in a has_many :through association. Model: Job class

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.