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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:37:14+00:00 2026-06-01T20:37:14+00:00

I guess I still don’t understand this yet. I’m not using ARC on this

  • 0

I guess I still don’t understand this yet. I’m not using ARC on this project.

For a propert, aProperty declared with the retain attribute, I would expect that the assigned object is retained twice in the following statement:

self.aProperty = [UIView alloc] init...];

Once from the alloc, and once by the setter.

So I release the object once immediately, like this:

self.aProperty = [UIView alloc] init...];
[self.aProperty release];

The compiler gives an error message:

Incorrect decrement of reference count of an object that is not owned at this point
by the caller.

Is the retain count incremented by the setter, making it two, at that point?

Also, what does “not owned at the point by the caller” mean? This could be a problem that I’m not familiar with.

  • 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-01T20:37:16+00:00Added an answer on June 1, 2026 at 8:37 pm

    To clarify what is happening.

    self.myVar = [[UIView alloc] initWithFrame:frame];
    

    is equivalent to calling

    [self setMyVar:[[UIView alloc] initWithFrame:frame]];
    

    When using a @property with retain it’s implementation would end up looking something like this (this is just a rough example)

    - (void)setMyVar:(UIView *)myVar;
    {
        if (_myVar != myVar) {
            [_myVar release];
            _myVar = [myVar retain];
        }
    }
    

    So now we can say that

    +----------- +1 retain ------------+
    |                                  |
    [[UIView alloc] initWithFrame:frame]
    

    and

    +------ +1 retain ----+
    |                     |
    _myVar = [myVar retain];
    

    which is +2 for the count. We then would have something like

    - (void)dealloc;
    {
        [_myVar release];
        [super dealloc];
    }
    

    which is -1, which just leaves us with a memory leak as there is stil +1 retain.

    The pattern I favour is

    UIView *myVar = [[UIView alloc] initWithFrame:frame];
    self.myVar = myVar;
    [myVar release]; myVar = nil;
    

    so that memory is released as soon as possible and no dangling pointers are left as it is nil‘led out

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

Sidebar

Related Questions

I guess I still don't get git as I'd hoped... I was creating a
This may seem like a dumb question, but still I don't know the answer.
Why app is still working, when i close it. I guess it is caused
Ok so sorry for being, I guess, a bit off topic but still I
I guess this is a simple question. I need to do something like this:
I guess that the # Net column is the most interesting, although I don't
I guess this is similar to what Facebook does, but...I haven't worked out how
I am still new to MVC, so sorry if this is an obvious question:
My problem is sample ...But I still don't know why my view won't push
I'm using Plone 4.0.5, and I've spent the day trying to understand plone.app.contentmenu. I

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.