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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:17:24+00:00 2026-05-23T23:17:24+00:00

I’m developing an iPad app and I ran into a really weird issue here.

  • 0

I’m developing an iPad app and I ran into a really weird issue here. I’ll try to explain it as good as possible.

I have a class named TranslationObject which is holding a key and a textual value. I have created this class as the following:

@interface TranslationObject : NSObject {
    NSNumber *_key;
    NSString *_value;
}

@property (nonatomic, retain) NSNumber *key;
@property (nonatomic, retain) NSString *value;

- (id) initWithKey:(NSNumber *) key andValue:(NSString *) value;

@end

The translations will be pulled from a XML or DB in the future, but for now I do the following:

@interface Translation : NSObject {
    NSMutableArray *m_extfeat;
}

@property (nonatomic, retain) NSMutableArray *extfeat;

+ (Translation *) getInstance;
- (id) init;
- (NSMutableArray *) getExtFeat;

@end

Implementation:

@implementation Translation

@synthesize extfeat = m_extfeat;

- (id) init {
    self = [super init];

    if (self) {
        m_extfeat = [[self getExtFeat] retain];
    }
    return self;
}

- (NSMutableArray *) getExtFeat {
    TranslationObject *obj1 = [[[TranslationObject alloc] initWithKey:[NSNumber numberWithInt: 0] andValue:@"Animal house"] autorelease];

    .... more items declared ....

    NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10, obj11, obj12, obj13, obj14, obj15, obj16, obj17, nil];

    return [array autorelease];
}
@end

These translations are being used in a UITableViewController and are being fetched in the viewDidLoad method as:

- (void)viewDidLoad
{
     _data = [[Translation getInstance].extfeat retain];
}

I use these values at its cellForRowAtIndexPath, where I call a method to configure the cell:

- (void) configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *) indexPath {
    TranslationObject *object = (TranslationObject *) [_data objectAtIndex:indexPath.row];

    //Crashes here at 13th item:
    NSLog("Object key: %@", [object.key stringValue]);
}

As the snippet above says, strangely, the app crashes when fetching the key value only if the _data array contains more than 12 items. So if I only fill the _data variable with 12 items or less, my code works fine. If I add more than 12, the app crashes as soon as it fetches the 13th object.

So I enabled NSZombies and so when I check the 13th item in that method, the value is still fine, but it’s only the key that turned into a Zombie. And again.. Only from the 13th item on!

Does anyone know how this is possible? Is it maybe so that there is a maximum number of items that can be stored in the memory? Is the memory full at the 12 item? But if that’d be the case, then why would the value still be there. How would it be possible that it’s just the key that is being released before?! And how?!

I hope this explanation makes sense and someone can shine a light over this case.. =/

Thanks!

EDIT: Here’s the implementation of the initWithKey method of the TranslationObject:

- (id) initWithKey:(NSNumber *) key andValue:(NSString *) value {

    self = [super init];

    if (self) {
        _key = key;
        _value = value;
    }

return self;
}

  • 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-23T23:17:25+00:00Added an answer on May 23, 2026 at 11:17 pm

    Make sure your using the property accessors in the TranslationObject or retaining the number:

    @implementation TranslationObject
    
    @synthesize key=_key, value=_value;
    
    - (id) initWithKey:(NSNumber *) key andValue:(NSString *) value {
        self = [super init];
        if (!self) return nil;
    
        self.key = key;  // ensures key is retained
        self.value = value;
    
        return self;
    }
    
    …
    
    @end
    

    Specifics:

    self.key = key;
    

    is the syntax for calling the accessor methods for the property; in this case the set accessor. Given you declared your property with the nonatomic and retain attributes as follows:

    @property (nonatomic, retain) NSNumber *key;
    

    the set accessor will look something like

    - (void)setKey:(NSNumber *)value {
        if (value != _key) {
            id old = _key;
            [value retain];
            _key = value
            [old release];
        }
    }
    

    The set accessor is automatically generated by the compiler when you added:

    @synthesize key=_key;
    

    Conversely, calling

    _key = key;
    

    simply copies the value of the pointer in key to _key, but does not retain the object referred to by key. TranslationObject does not assume ownership of key. If you did not want to use the accessor, the correct implementation would be

    _key = [key retain];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.