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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:50:24+00:00 2026-05-15T21:50:24+00:00

The setting is the following: I have a cocoa object in a nib file

  • 0

The setting is the following:

  • I have a cocoa object in a nib file that is loaded when the NSWindow and view is loaded
  • The window can be closed
  • I also access the object programmatically

Now what happens in some situations is that I get a crash, when I try to send a message to the object, but it has been deallocated before (because the window is closed). The crash looks like this:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV) 
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000017 
Crashed Thread:  0  
Dispatch queue: com.apple.main-thread

Application Specific Information: 
objc_msgSend() selector name: ...

Is there any way to check if the object is available or not? Checking for nil does not work, it is not nil. Probably the control flow is not perfect, and I could rewrite other chunks of the app to make this problem go away, but I think this is a more general problem that I have no solution for, and it boils down to this:

How can I make sure that an object that is loaded from a nib is set to nil on deallocation?

  • 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-15T21:50:25+00:00Added an answer on May 15, 2026 at 9:50 pm

    I guess you could use Interfacebuilder to write your Window-class and in its dealloc method you could set the VARIABLE to nil. But you cannot set the object itself to nil. the variable saves a pointer to the object, if its deallocated the pointer points to a place in memory where anything could be.

    So if you access said object from another class, you have another variable, so setting the one in your windows-class to nil, wouldnt be useful at all.

    The solution is quiet simple, since the window-class sends this object a release message when the window get deallocated, you should retain your object bevor you use it in another class, and then release it when youre done with it.

    If you use a property for your object with the retain-attribute dont forget to call the setter with self.object = … without property it could look sth like this:

    so you need to retain your object bevor the window gets closed. maybe in the first viewDidLoad-method that gets called by your app:

    
    ...
    - (void)viewDidLoad {
    otherClassObject.YOUROBJECT = [self.YOUROBJECT retain];

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

Sidebar

Related Questions

I have set the following setting in my app's -info.plist file, but still when
setting is the following: I have a homepage where I display a diagram that
If I have the following setting in my app.config file. It is a setting
We have a CI installation that has the following setting in our config... $config['enable_query_strings']
We have the following setting: There is a web application which has a jboss
I have following this blog in setting Xvfb in my ubuntu environment: http://corpocrat.com/2008/08/19/how-to-install-xvfb-x11-server-in-linux-server/ So
I have followed the following instructions in setting a git repository locally in one
I'm using a Table View in a Cocoa application. I have set the double
I have the following code to start my own Cocoa HTTP Server . In
I have the following setting: class Baguette(models.Model): # fields class Pizza(models.Model): # fields class

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.