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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:06:24+00:00 2026-05-18T05:06:24+00:00

I was trying to display the contents of an array into a table view.

  • 0

I was trying to display the contents of an array into a table view. The table view has single column. My class is RKCandidate which is a subclass of NSWindowController. RKCandidate is also the Owner of the ‘nib’ file In IB I have selected the File’s Owner as the dataSource of the tableview.

There are the methods I’m using to update the tableview,

- (id) initWithClient:(TextInputController *) client
{
 self = [super initWithWindowNibName:@"RKCandidate"];
 if (self != nil) {
  _client = client;

 }
 return self;
}

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

 NSLog(@"updateCandidate Called.\n");

 optionsArray = [_client composedStringArray:self];
 [candidateOptions reloadData];

 NSLog(@"Retain Count of OptionsArray: %i\n",[optionsArray retainCount]);
 NSLog(@"Object Count of OptionsArray: %i\n",[optionsArray count]);
 NSLog(@"Address of Object: %i\n",[optionsArray objectAtIndex:0]);
 NSLog(@"Object: %@\n",[optionsArray objectAtIndex:0]);
 //NSString *benChar = [optionsArray objectAtIndex:0];
 //NSLog(@"Object Retain Count: %@i\n",[benChar retainCount]);
  }
#pragma mark TableView Data Source Methods
#pragma mark -

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {

 NSLog(@"Retain Count of OptionsArray: %i\n",[optionsArray retainCount]);
 NSLog(@"Object Count of OptionsArray: %i\n",[optionsArray count]);
 NSLog(@"Address of Object: %i\n",[optionsArray objectAtIndex:0]);
 NSLog(@"Object: %@\n",[optionsArray objectAtIndex:0]);
 //NSLog(@"Object Retain Count: %@i\n",[[optionsArray objectAtIndex:0] retainCount]);

 return [optionsArray count];
}

- (id)tableView:(NSTableView *)aTableView 
     objectValueForTableColumn:(NSTableColumn *)aTableColumn 
    row:(NSInteger)rowIndex {

 NSLog(@"Retain Count of OptionsArray: %i\n",[optionsArray retainCount]);
 NSLog(@"Object Count of OptionsArray: %i\n",[optionsArray count]);
 NSLog(@"Address of Object: %i\n",[optionsArray objectAtIndex:0]);
 NSLog(@"Object: %@\n",[optionsArray objectAtIndex:0]);
 //NSLog(@"Object Retain Count: %@i\n",[[optionsArray objectAtIndex:0] retainCount]);

 return [optionsArray objectAtIndex:rowIndex];
}

The optionsArray is updated by a simple method from client the method is as follows,

-(NSMutableArray *) composedStringArray:(id)sender {

 NSLog(@"returning composedStringArray.\n");

 return convertBufferArray;
}

convertBufferArray is a mutable array.

When the updateCandidate method is called for the first time. It works nicely. But problem starts when I call it second time after updating the convertBufferArray array inside the client.

When the updateCandidate method is called from the first time the Console log is as follows:

2010-11-20 09:03:35.385 Input Method Tester[7225:a0f] Retain Count of OptionsArray: 1
2010-11-20 09:03:35.385 Input Method Tester[7225:a0f] Object Count of OptionsArray: 1
2010-11-20 09:03:35.386 Input Method Tester[7225:a0f] Address of Object: 1372384
2010-11-20 09:03:35.386 Input Method Tester[7225:a0f] Object: ∆
2010-11-20 09:03:35.392 Input Method Tester[7225:a0f] Retain Count of OptionsArray: 1
2010-11-20 09:03:35.392 Input Method Tester[7225:a0f] Object Count of OptionsArray: 1
2010-11-20 09:03:35.393 Input Method Tester[7225:a0f] Address of Object: 1372384
2010-11-20 09:03:35.393 Input Method Tester[7225:a0f] Object: ∆
2010-11-20 09:03:35.397 Input Method Tester[7225:a0f] Retain Count of OptionsArray: 1
2010-11-20 09:03:35.397 Input Method Tester[7225:a0f] Object Count of OptionsArray: 1
2010-11-20 09:03:35.398 Input Method Tester[7225:a0f] Address of Object: 1372384
2010-11-20 09:03:35.399 Input Method Tester[7225:a0f] Object: ∆

The table view displays the content of the array.

But when I just add another letter to the Object string, some how, the string gets replaced with an empty string when the – (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex is called. The log is as follows.

2010-11-20 09:03:38.349 Input Method Tester[7225:a0f] returning composedStringArray.
2010-11-20 09:03:38.350 Input Method Tester[7225:a0f] Retain Count of OptionsArray: 1
2010-11-20 09:03:38.351 Input Method Tester[7225:a0f] Object Count of OptionsArray: 1
2010-11-20 09:03:38.352 Input Method Tester[7225:a0f] Address of Object: 1372384
2010-11-20 09:03:38.353 Input Method Tester[7225:a0f] Object: ƍ
2010-11-20 09:03:38.354 Input Method Tester[7225:a0f] Retain Count of OptionsArray: 1
2010-11-20 09:03:38.354 Input Method Tester[7225:a0f] Object Count of OptionsArray: 1
2010-11-20 09:03:38.354 Input Method Tester[7225:a0f] Address of Object: 1372384
2010-11-20 09:03:38.355 Input Method Tester[7225:a0f] Object: ƍ
2010-11-20 09:03:38.358 Input Method Tester[7225:a0f] Retain Count of OptionsArray: 1
2010-11-20 09:03:38.358 Input Method Tester[7225:a0f] Object Count of OptionsArray: 1
2010-11-20 09:03:38.359 Input Method Tester[7225:a0f] Address of Object: 1372384
2010-11-20 09:03:38.359 Input Method Tester[7225:a0f] Object: 

As you can see in the list line of the above log the string is empty. The tableView become empty.

Is there anything wrong I’m doing? I’ve tried putting the release and retaining the optionsArray but the result is the same. I also tried to copy the content of the composedBufferArray into the the optionsArray. I tried putting

optionsArray = [_client composedStringArray:self];

into the init method. The result is the same for all the cases.

Please help. I couldn’t solve this problem for last two days. Please help.

Sorry I couldn’t post a image or a link as I’m totally new in Stack Overflow.

Regards,

Raiyan

  • 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-18T05:06:25+00:00Added an answer on May 18, 2026 at 5:06 am

    First:

    Do not call retainCount

    It is useless for debugging and the returned number is often quite thoroughly misleading. For starters, an object can never return a 0 for the retain count and, thus, trying to find over-released object using retainCount is entirely futile.

    Your bug looks like a memory management issue. That it isn’t crashing is simply luck.

    You should read the Cocoa Memory Management Guide a couple of times (until it sinks in — when I started w/Objective-C, I found reading the language docs a few times was tremendously valuable).

    Your -init method looks suspect; _client = client; will not retain _client.

    You should also use “build and analyze” on your code. The llvm static analyzer will identify most memory management issues in your code.

    Finally, learn to use the zombie detection instrument. See some of the answers here for more information.

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

Sidebar

Related Questions

I’m trying to display a swf from another site into mine. I’ve got permission
Currently we have a table with a bunch of data from a database which
I am trying to get a pie chart display correctly but have found there
I'm trying to create a small app that takes a base text template with
Im trying to access the Magento customer session in another part of my website.
I'm using Zend_View_Helper_HeadScript to display javascript function definitions in the head of my webpages,
I'm trying to create a custom search but getting stuck. What I want is
I am trying to extend the Upload library in CodeIgniter. I have been trying
First of all, i'm a Graphic designer so please ignore if this programming question
I've been tinkering around with Zend-Framework and Jquery for a month or so, and

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.