On Apr 20, 2009, at 11:12 AM, Gerriet M. Denkmann wrote:

NSArray *defs = ...some array... (which is bound to content of definitionsArrayController)
NSUInteger defIndex = 0;
for( NSDictionary *aDef in defs )
{
        for( NSString *defKey in aDef )
        {
                NSString *value = [ aDef objectForKey: defKey ];
                BOOL ok = ... some test with value      
                if ( !ok )      //      select the bad thing
                {
[ definitionsArrayController setSelectionIndex: defIndex ]; // this works fine // now the table shows "aDef" and the first row in the table is selected [ myDictionaryController setSelectedObjects: [ NSArray arrayWithObject:

This doesn't work because the selected object(s) need to be the actual objects managed by the controller.

This code works (but seems incredibly complicated and inefficient):

NSArray *arrangedObjects = [ dictController arrangedObjects ];
id theThing = nil;
for( id something in arrangedObjects )
{
        NSString *key = [ something key ];
        if ( [ key isEqualToString: defKey ] )
        {
                theThing = something;
                break;
        };      
};

if ( theThing == nil )  //      error
{
        NSLog(@"%s Error not found",__FUNCTION__);
}
else
{
[ dictController setSelectedObjects: [ NSArray arrayWithObject: theThing ] ];
};


This, or something similar, is probably your best bet. Also, chances are any other apparently shorter solution would really just do the same thing.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to