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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:11:02+00:00 2026-06-05T21:11:02+00:00

In an iOS class that will not appear as a view e.g. @interface MyDataClass

  • 0

In an iOS class that will not appear as a view e.g.

@interface MyDataClass : NSObject{}

Is there a method that can be overridden and is consistently called at the end of the classes’ execution/lifecycle similar to viewDidUnload or dealloc, that can call methods safely?

Alternatively how would one go about implementing a method that could recognise the completion of the useful lifespan of such a class?

  • 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-05T21:11:03+00:00Added an answer on June 5, 2026 at 9:11 pm

    If you mean a method that runs at the end of lifetime of the Class as a whole (not an instance), I wonder how is the runtime supposed to know when you are done using a class (you can create new instances at any time)? There is an +initialize method, but technically the class itself is available forever (until the program exits).

    If you mean the lifetime of an instance, the method you are looking for is -dealloc.

    -dealloc is called whenever an object’s internal reference count reaches zero. In non-ARC code, if you override it you must call the superclass’ implementation, so that ultimately NSObject‘s -dealloc is called and that is when the memory is freed.

    EDIT: Regarding low memory situations, this is how you register for notifications:

    // Somewhere inside the -init method of your class
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(myMethod:) 
                                                 name:UIApplicationDidReceiveMemoryWarningNotification 
                                               object:nil];
    

    Inside dealloc, you MUST do this:

    [[NSNotificationCenter defaultCenter] removeObserver:self];
    

    …otherwise, your app may crash.

    And of course, you must implement a method with the following signature that will be called on low-memory situations:

    - (void) myMethod:(NSNotification*) notification
    {
       // Do some cleanup here, perhaps.
    }
    

    (otherwise, your app will crash)

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

Sidebar

Related Questions

I noticed that there is no dealloc method already placed in various class files
I have a Login class that will parse an xml sent from an iOS,
In an iOS app, I'm writing a class that will be messaged, go do
Recently I was repairing someone's code. There was a big class that would not
I am new to iOS and Objective-C, I already know that in a class,
In iOS, how can I call an Objective-C method from Javascript in a UIWebView
I am writing a network class for an iOS app. This class will take
When I create a new shared iOS library CoreServices then there is a class
Since recent runtimes in iOS, we are able to define properties that will generate
Assume that I have a class with a readonly property on it. //MyClass.h @interface

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.