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

  • Home
  • SEARCH
  • 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 3235904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:33:37+00:00 2026-05-17T17:33:37+00:00

I am creating an application and I get an EXC_BAD_ACCESS error. CODE @interface DNProjectsCategory

  • 0

I am creating an application and I get an EXC_BAD_ACCESS error.


CODE

@interface DNProjectsCategory : DNCategory {
  NSArray *projects;
}

@property(nonatomic, retain) NSArray *projects;

@end

And:

@implementation DNProjectsCategory
@synthesize projects;

// MEM

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

// INIT.
- (id)init {
  if (self = [super init]) {
    title = NSLocalizedString(@"PROJECTS", nil);
    isSubCategory = NO;
    
    // Initialize projects
    //!!LINE 32 IS HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    projects = [NSArray arrayWithContentsOfFile:DNPROJECTSFILE];
  }
  
  return self;
}

// CATEGORIES

- (NSArray *)subCategories {
  NSMutableArray *projectsArray = [[[NSMutableArray alloc] init] autorelease];
  
  for (NSDictionary *project in projects) {
    DNCategory *projectCategory = [[DNCategory alloc] initWithTitle:[project valueForKey:@"title"]
                                                      subCategories:nil
                                                      isSubCategory:YES];
    
    [projectsArray addObject:projectCategory];
    [projectCategory release];
  }
  
  return projectsArray;
}

CONTENTS OF DNPROJECTSFILE

See http://gist.github.com/618628


CONSOLE & INSTRUMENTS

This is what the Console says when ran (NSZombie is enabled):

run
[Switching to process 41257]
Running…
2010-10-09 23:32:36.899 Done[41257:a0f] *** -[CFString isKindOfClass:]: message sent to deallocated instance 0x1001caab0
sharedlibrary apply-load-rules all

Here is what Instruments says in an NSZombie test:

Zombie Messaged

An Objective-C message was sent to a deallocated object (zombie) at address: 0x10012af80.

 

Stack Trace

   0 CoreFoundation _CFRuntimeCreateInstance
   1 CoreFoundation __CFStringCreateImmutableFunnel3
   2 CoreFoundation CFStringCreateWithBytes
   3 CoreFoundation _uniqueStringForCharacters
   4 CoreFoundation getString
   5 CoreFoundation parseXMLElement
   6 CoreFoundation parseXMLElement
   7 CoreFoundation parseArrayTag
   8 CoreFoundation parseXMLElement
   9 CoreFoundation parsePListTag
  10 CoreFoundation parseXMLElement
  11 CoreFoundation _CFPropertyListCreateFromXMLStringError
  12 CoreFoundation _CFPropertyListCreateWithData
  13 CoreFoundation CFPropertyListCreateFromXMLData
  14 Foundation _NSParseObjectFromASCIIPropertyListOrSerialization
  15 Foundation +[NSArray(NSArray) newWithContentsOf:immutable:]
  16 Foundation +[NSArray(NSArray) arrayWithContentsOfFile:]
  17 Done -[DNProjectsCategory init] /Users/rsonic/Developer/Done/DNProjectsCategory.m:32
  18 Done -[DNBindingsController categories] /Users/rsonic/Developer/Done/DNBindingsController.m:18
  19 Foundation -[NSObject(NSKeyValueCoding) valueForKey:]
  20 Foundation -[NSObject(NSKeyValueCoding) valueForKeyPath:]
  21 AppKit -[NSBinder valueForBinding:resolveMarkersToPlaceholders:]
  22 AppKit -[NSArrayDetailBinder _refreshDetailContentInBackground:]
  23 AppKit -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:]
  24 AppKit -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:]
  25 AppKit loadNib
  26 AppKit +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:]
  27 AppKit +[NSBundle(NSNibLoading) loadNibNamed:owner:]
  28 AppKit NSApplicationMain
  29 Done main /Users/rsonic/Developer/Done/main.m:13
  30 Done start

QUESTION

I really don’t know how to fix this double-release. For as far as I know I don’t release the projects variable anywhere except in dealloc. Can somebody help me, please? 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-17T17:33:37+00:00Added an answer on May 17, 2026 at 5:33 pm

    You are not using the accessor, so projects is never retained.
    Two choices for your init method:

    projects = [[NSArray arrayWithContentsOfFile:DNPROJECTSFILE] retain];
    

    or

    self.projects = [NSArray arrayWithContentsOfFile:DNPROJECTSFILE];
    

    @property(nonatomic, retain) NSArray *projects;
    

    the property “creates” two methods, a getter - (NSArray *)projects and a, in your case more important, setter - (void)setProjects:(NSArray*)a; The retain statement which you wrote in your property declaration only applies to the setter. If you set the variable directly with projects = foo; the setter is not used.
    But self.projects = foo; is equivalent to [self setProject:foo], which is your dynamically created setter.
    Your setter looks similar to this:

    - (void)setProjects:(NSArray*)anArray {
        [anArray retain];
        [projects release];
        projects = anArray;
    }
    

    So if you use the setter, your autoreleased NSArray you got from arrayWithContentsOfFile: is retained.
    Every call you make in Objective C that is not “alloc”, “copy”, “retain” or anything starting with new returns an autoreleased object. You have to retain those if you want to use them later (i.e. after you left the method where they were created).

    Maybe you want to take another look at the Apple Memory Managment Guide

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

Sidebar

Related Questions

I am creating a gwt application.I get the error The constructor Random() is not
I'm creating an application that will get the contents of a cookie storing a
I am creating a java application and I need to get the user PINs
I am creating a web application with back-end on ISeries. In the page load
I am creating a simple application to get familiar with SlimDX library. I found
I'm creating an application in Objective-C and I need to get the metadata from
I'm creating an application which lets you define events with a time frame. I
I'm creating an application that will store a hierarchical collection of items in an
I'm currently creating an application for a customer that will allow them to automatically
I am creating an application in java which will be the part of an

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.