Table view does not update according to bindings

This is a very newbie question, and this is what I have done many times before, but there is something missing for me this time.

In my AppDelegate.h file, I declare 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 select it:

lines = [[NSArray alloc] init];

Then I have a method that sets up an array of strings:

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

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

Is there something obvious I'm missing here?

0
3

, Bindings. .

, "AppDelegate.self.lines"...

self?

@property (readwrite, ) NSArray * lines;

, copy . , - , . "" , .

, :

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

. , . KVO, .

, ( , ) . , . setLines:, .

:

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

- , ( , @property, ), KVO.

+4

, , , tablview? tableview

+2

You may want to read this ; it has good charts and explanations. What ennuikiller says correctly, I think this is a problem with your data source. This is done by calling

[aTable setDelegate:aDelegate];
0
source

All Articles