Re: programatically updating UI for NSArrayContoller/NSTableView combo
Re: programatically updating UI for NSArrayContoller/NSTableView combo
- Subject: Re: programatically updating UI for NSArrayContoller/NSTableView combo
- From: Russell Gray <email@hidden>
- Date: Sun, 10 Jan 2010 09:15:01 +1100
I have a controller object "Controller" of Class Name "AdBlockerPreferences", with the outlet connected to the Array Controller. the Array Controller's content is bound to Controller.subscriptions
the Array Controller has the preference "Prepares Content" checked.
.....I also have File's Owner with the Class identity of "AdBlockerPreferences" could this be my problem?
in my AdBlockerPreferences.h file just the relevant stuff:
AdBlockerPreferences : NSPreferencesModule
{
IBOutlet id subscriptionTableView;
IBOutlet id subscriptionsArrayController;
NSMutableArray* subscriptions;
}
- (NSMutableArray *)subscriptions;
- (void)openABPFeed:(NSURL*)feed;
@property (retain) id subscriptionTableView;
@property (retain) id subscriptionsArrayController;
@property (retain,getter=subscriptions) NSMutableArray* subscriptions;
and my AdBlockerPreferences.m
@implementation AdBlockerPreferences
@synthesize subscriptionTableView, subscriptions, subscriptionsArrayController;
- (id) init {
if (self = [super init]) {
// build up some sample data
subscriptions = [[NSMutableArray alloc] init];
NSString *applicationSupportFolder = [SABApplicationSupportFolderPath stringByExpandingTildeInPath];
NSString *subscriptionsPlistPath = [applicationSupportFolder stringByAppendingPathComponent:SABSubscriptionsPlistFullName];
NSArray* subscriptionsArray = [NSArray arrayWithContentsOfFile:subscriptionsPlistPath];
int i = 0;
for (NSDictionary *child in subscriptionsArray)
{
NSDictionary* subscriptionsDictionary = [subscriptionsArray objectAtIndex:i];
SubscriptionInfo* subscriptionInfo = [[[SubscriptionInfo alloc] initWithInfoDictionary: subscriptionsDictionary] autorelease];
[subscriptions addObject: subscriptionInfo];
i++;
}
}
return self;
}
- (void) dealloc {
[subscriptions release];
[subscriptionsArrayController release];
[super dealloc];
}
- (NSMutableArray*) subscriptions {
return subscriptions;
}
- (void)openABPFeed:(NSURL*)feed
{
/////////////////////////removed
// Create our Subscriptions plist file.
NSDictionary *output;
output = [NSDictionary dictionaryWithObjectsAndKeys:title, @"feedNameKey",
urlString, @"feedURLKey",
defaultValue, @"feedUpdatedKey", nil];
SubscriptionInfo* subscriptionInfo = [[[SubscriptionInfo alloc] initWithInfoDictionary: output] autorelease];
[subscriptionsArray addObject:output];
// Write the Subscriptions plist file.
[subscriptionsArray writeToFile:subscriptionsPlistPath atomically:YES];
//////////none of these are working...
//[subscriptionsArrayController addObject: subscriptionInfo];
//[[self mutableArrayValueForKey: @"subscriptions"] addObject: subscriptionInfo];
//[[self mutableArrayValueForKey: @"subscriptions"] insertObject: subscriptionInfo atIndex: [subscriptions count]];
//[subscriptionsArrayController insertObject: subscriptionInfo atArrangedObjectIndex: [[subscriptionsArrayController arrangedObjects] count]];
int x = [subscriptionsArray count];
[[[[AdBlockerUpdater alloc] init] autorelease] updateFeedWithPreferences:self atIndex:x];
}
and I call open openABPFeed: from another class, like so:
[[AdBlockerPreferences sharedInstance] openABPFeed:[request URL]];
I also tried this (just to make sure its happening on the main thread:
[[AdBlockerPreferences sharedInstance] performSelectorOnMainThread:@selector(openABPFeed:) withObject:[request URL] waitUntilDone:YES];
not sure what else I would need to do?
On 10/01/2010, at 8:59 AM, mmalc Crawford wrote:
>
> On Jan 9, 2010, at 1:50 pm, Russell Gray wrote:
>> On 10/01/2010, at 8:18 AM, Quincey Morris wrote:
>>> How about if you register your own KVO observer of the "subscriptions" property? Does it get notified when the property changes? Did you check the log for exception error messages?
>> So, I added an observer to my awakeFromNIb:
>> [subscriptionsArrayController addObserver: self
>> forKeyPath: @"arrangedObjects"
>> options: NSKeyValueObservingOptionNew
>> context: NULL];
>>
>
> Quincey did suggest observing the subscriptions property...
>
>> what would be my next plan of attack here?
>>
> Re-read the KVO Programming Guide and the Cocoa Bindings Programming Guide, and review the myriad examples that show how to do this to see how yours differs.
> Seeing the code you're using to modify the subscriptions property would also be useful.
>
> mmalc
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden