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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:40:08+00:00 2026-05-22T22:40:08+00:00

I am new to cocoa-touch, and really unmanaged languages all together. While I have

  • 0

I am new to cocoa-touch, and really unmanaged languages all together. While I have a firm grasp of the syntax, I am questioning whether I am releasing an object correctly.

I have a view that creates an object,

Communication *comm = [[Communication alloc] init];
[comm doSomething];
[comm release];

I understand that I have to destroy this object because I am allocating it and it will not auto release.

I call a method on the object that goes out to my server and grabs information. When the data returns it throws an event which my “message dispatcher” responds to. I do not want to destroy the object until it returns back from the server — and this is where my confusion is at.

  1. If I release this object directly after I make the call, will it destroy the object? (Which I don’t want to do.)
  2. How do I properly destroy this object after it throws the event with the data I am waiting for? This would occur within a DataFinishedLoading event on my comm object. Should it destroy itself, and is this the right way to do it?

The view calling my object essentially says, create this object, call this method, and go about your merry way. It doesn’t care about what happens after it calls the method — whether it brings back information or not. It simply listens on a method for any data that may come across at a later time. I have no reason to hang onto a reference of the object, as I will never use the same instance after I make the call — that is besides cleaning up after myself.

  • 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-22T22:40:09+00:00Added an answer on May 22, 2026 at 10:40 pm

    A release only destroys the object if the last retainer released it.

    For example, say you allocate your Communication object. It is implicitly retained once. Then you retain it five times. You need to release/autorelease the object six times until it gets destroyed (its dealloc method is called).

    There is an internal counter, the retainCount. When you create an object, it is set to 1. Now every retain increases the counter, and every release decreases it. autorelease also decreases the counter, but not immediately. Once the counter drops to 0 Objective-C knows that the object is no longer needed and destroys it (by calling the object’s dealloc). Warning: do not rely on the retainCount, do not even look at it. You should only care that your alloc/copy/new/retain calls are balanced with a corresponding release/autorelease later on.

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

Sidebar

Related Questions

I have done quite some cocoa-touch stuff, but am still new to cocoa. I
I am new to cocoa touch programming. Is there a widget/control in cocoa touch
I'm fairly new to Cocoa. I was talking to my brother, who's put together
I'm still very new to cocoa touch so please excuse any terminology that I
I'm new in Cocoa-Touch. Please look at this links: http://www.youtube.com/watch?v=Cab8CB_Lzbw http://www.youtube.com/watch?v=8c8KA1uZ9F8&feature=autoplay&list=PL6EFB1A1E5CAA7666&lf=results_main&playnext=1 I really want
I have two cocoa-touch apps in one Xcode project. Xcode gives me iPhone/iPad related
I'm new to Cocoa/Cocoa Touch, and working through a development book. I've come across
1. Step: Create a new UIViewController: - Xcode -> New File... -> Cocoa Touch
I am really new to iPhone dev. I am evaluating whether to use Monotouch
I'm new to Cocoa Touch and I'm just messing around trying to get a

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.