• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Subclassing Catch-22
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing Catch-22


  • Subject: Re: Subclassing Catch-22
  • From: Marco Scheurer <email@hidden>
  • Date: Tue, 26 Apr 2005 23:45:54 +0200


On Apr 26, 2005, at 23:17, Todd Ransom wrote:

The code looks like this:

- (NSString *)bindingKeyForTableColumnIdentifier: (NSString *) identifier {

NSArray *keys = [NSArray arrayWithObjects: @"name", @"notes", @"status", nil];
NSArray *identifiers = [NSArray arrayWithObjects: @"Name", @"Notes", @"Status", nil];


NSDictionary *keyForIdentifier = [dictionaryWithObjects: keys forKeys: identifiers;

    return [keyForIdentifier valueForKey: identifier];
}

- (BOOL) tableViewAddColumnWithIdentifier: (NSString *)identifier {

NSString *bindingKey = [self bindingKeyForTableColumnIdentifier: identifier];

    [create a table column, bind it, add it to a table]

}

The theory was that subclasses would override both methods, returning the appropriate key to bind to and implementing whatever specifics were required for the table column (popup button cells, date formatters, etc.).

It all worked fine except I wanted the subclasses to defer to super for columns shared by all views.

Maybe bindingKeyForTableColumnIdentifier in subclasses needs to augment the dictionary of the superclass? That would be easier with a dictionary method you can override:


- (NSDictionary *) keyForIdentifierDictionary
{
NSMutableDictionary *keyForIdentifier = [NSMutableDictionary dictionaryWithObjectsAndKeys...];
[keyForIdentifier addEntriesFromDictionary:[super keyForIdentifierDictionary]];
return keyForIdentifier;
}


marco

Marco Scheurer
Sen:te, Lausanne, Switzerland   http://www.sente.ch

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Subclassing Catch-22
      • From: Ondra Cada <email@hidden>
References: 
 >Subclassing Catch-22 (From: Todd Ransom <email@hidden>)
 >Re: Subclassing Catch-22 (From: Marco Scheurer <email@hidden>)
 >Re: Subclassing Catch-22 (From: Todd Ransom <email@hidden>)
 >Re: Subclassing Catch-22 (From: Greg Titus <email@hidden>)
 >Re: Subclassing Catch-22 (From: Todd Ransom <email@hidden>)

  • Prev by Date: Re: How can a view know when its superview changes sizes?
  • Next by Date: Re: Programmatically determine keys in an controller
  • Previous by thread: Re: Subclassing Catch-22
  • Next by thread: Re: Subclassing Catch-22
  • Index(es):
    • Date
    • Thread