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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:21:38+00:00 2026-05-27T02:21:38+00:00

I have created an iphone application using the empty template without ARC in xcode

  • 0

I have created an iphone application using the empty template without ARC in xcode 4.2. I’m not currently using ARC because I want to learn the basics of reference counting. In the application delegate I have the following method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
 }

Why is window autoreleased? Is it because AppDelegate won’t be using it in the future? But it is being assigned to a instance variable. There is also a dealloc method where window is released. Why is it released when it is already autoreleased?

- (void)dealloc
{
    [_window release];
    [super dealloc];
}
  • 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-27T02:21:39+00:00Added an answer on May 27, 2026 at 2:21 am

    The property of the window in .h file is declared as @property (nonatomic, retain) UIWindow *window;. The window has a retain property. So the UIWindow is retained by the setter method of the window variable.
    In the line self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; the new window alloced has +1 in retainCount because of the alloc and another +1 because of the window setter method resulting in a +2 retainCount. The autorelease is to decrease the retainCount back to +1. In the dealloc the retainCount goes to 0 and the window is deallocated.

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

Sidebar

Related Questions

I have created one application using XCode. Now i want to deploy that application
I am new to iPhone development.I have created an application using UITableViewCellAccessoryDisclosureIndicator . I
I have created in-app purchase for non-consumable object application in iPhone using with store
I am new to iphone development.I have created a view based application.Now i want
I have created an iPhone application. Using this application, I can able to record
I'm creating my first iPhone application (using XCode 4), and I initially created the
I have created iphone bluetooth chat application using following tutorial:http://www.devx.com/wireless/Article/43502/1954. It works well.But when
I am new to iphone development, i have created sms application using Text Links(sms:)
I created an empty Single View application using Xcode 4.2 on OSX Lion 10.7.2
I have created an iPhone application based on an OpenGL view. Now I would

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.