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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:03:16+00:00 2026-05-12T10:03:16+00:00

This is a very newbie question, and this is something I have done many

  • 0

This is a very newbie question, and this is something I have done many times before, but there’s something I’m missing this time.

In my AppDelegate.h file I declare an NSArray and set it as a property:

@interface AppDelegate : NSObject {
NSArray *lines;

}

@property(readwrite, retain) NSArray *lines;
@end

And then in the AppDelegate.m file in the awakeFromNib method I alloc it:

lines = [[NSArray alloc] init];

Then I have a method that sets the lines array:

NSString *fileContents = [NSString stringWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop/sometextfile.txt"] encoding:NSUTF8StringEncoding error:NULL];
lines = [fileContents componentsSeparatedByString:@"\n"];

I have an array controller thats bound to AppDelegate.self.lines then I have a table column bound to Array Controller.arrangedObjects. I can confirm that the array is being updated (tested using NSLog) however the contents of the table are not being update (it remains blank).

Is there something obvious I’m missing here?

  • 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-12T10:03:16+00:00Added an answer on May 12, 2026 at 10:03 am

    You don’t need a data source if you’re using Bindings. One or the other.

    I have an array controller thats bound to “AppDelegate.self.lines” …

    Why self?

    @property(readwrite, retain) NSArray *lines;

    No, use copy here. Otherwise, you’ll find yourself retaining someone else’s mutable array, which they will then mutate. Then “your” array will have changed without you knowing it.

    Then I have a method that sets the lines array:

    lines = [fileContents componentsSeparatedByString:@"\n"];
    

    This is why the table doesn’t show anything. You’re not going through the property, you’re accessing the instance variable directly. Direct instance variable accesses do not cause KVO notifications, so the array controller never finds out about the change.

    Even worse, you’re leaking the old array (since you simply assign over it without releasing it) and under-retaining this new array. Because you’re not retaining the new array, that instance variable will hold a dead object shortly. The automatic retaining is done by the setLines: method, which only gets called when you call it.

    You need to go through the property:

    self.lines = [fileContents componentsSeparatedByString:@"\n"];
    

    A property access is an implicit accessor message, so this both retains the array (or copies it, once you correct the @property as I suggested above) and posts KVO notifications.

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

Sidebar

Related Questions

This is a very newbie question, but something completely new to me. In my
This must be a very stupid newbie question, but I have spent my whole
This might be a very newbie question, but I didn't find anything satisfying I
This is likely a very simple question with a straightforward answer but I'm something
This is a very standard newbie question, but I am looking for an expert
This is probably a very newbie question but what I'm trying to do is
Okay, this is probably a very newbie question, but how can I get to
I am sorry for the very newbie question, but this is driving me mad.
this is really a newbie question, but it would help me to have a
Sorry this is a very newbie question. We have this massive application I am

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.