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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:11:59+00:00 2026-05-26T12:11:59+00:00

Suppose that i have UIView viewLoading declared in .h. and i do not directly

  • 0

Suppose that i have UIView viewLoading declared in .h. and i do not directly initialize it (in the first code).

The first Code.

 UIView *viewLoading2 = [[[UIView alloc] initWithFrame:CGRectMake(75 , 155, 170.0, 170.0)]];
 viewLoading = viewLoading2;
 [viewLoading2 release]

The second code:

viewLoading = [[[UIView alloc] initWithFrame:CGRectMake(75 , 155, 170.0, 170.0)]];

The third Code:

- (void) viewLoad:(UIView *) viewLoading2
{
  viewLoading = viewLoading2;
  //do i need to retain, alloc, or release something here?

}
  1. 2In the first code, do i need to release viewLoading in dealloc ? And what happen if i do not declare its property?

  2. In the second code, does it have same effect from the first code? (need to dealloc or not).

  3. For the third code, does it have same effect from the first code? and what should i do after i code that? (see the comment)

  4. Do iPhone Code always need to have release for variable declared in .h? Or only if the variable declared in .h is allocated? if like in the first code, do i need to dealloc viewLoading?

  5. what is the different between

    self.viewloading = viewLoading2;

and

viewloading = viewLoading2; 

Thanks

  • 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-26T12:11:59+00:00Added an answer on May 26, 2026 at 12:11 pm

    In the first example, you allocated the object (once), and you released it (once), so you don’t need to do anything else. On the other hand, viewLoading is invalid as soon as you send the release to viewLoading2, so it’s not very useful code.

    In the second, you have not released viewLoading yet, so it does need to be done eventually.

    In the third, whatever code allocated the object that was passed into this method via the parameter is responsible for releasing it. It should be valid for the duration of this method, but if you’re saving it for later use you need to retain it here, then release it when you’re done.

    Edit:

    I’m not sure I understand your question 4. A declaration in the interface (.h) file is just reserving space for a pointer. It’s not an object declaration, so there’s no release required until you actually do an object allocation.

    self.viewloading = viewLoading2 is using the properties setter method to do the assignment. If the @property statement has “retain” in it, then a retain is done as part of that assignment. `viewloading = viewLoading2″ is a straight assignment, no retain.

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

Sidebar

Related Questions

Suppose that you have two huge files (several GB) that you want to concatenate
Suppose that I have a Java program within an IDE (Eclipse in this case).
Suppose that I have a Java class with a static method, like so: class
suppose that I have this RDBM table ( Entity-attribute-value_model ): col1: entityID col2: attributeName
Suppose that I have the model Foo in GAE and this query: query =
Suppose that I have a request handler that accepts an argument: key And let
Suppose that you have to set 12 cookies, would it be better to store
Suppose that I have an integer variable in a class, and this variable may
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
Suppose that we have a class called class1. The class1 has a method called

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.