• 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
NSMutableArray Category as NSComboBoxDataSource?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMutableArray Category as NSComboBoxDataSource?


  • Subject: NSMutableArray Category as NSComboBoxDataSource?
  • From: Frank DiRocco <email@hidden>
  • Date: Thu, 16 Jul 2009 23:00:12 -0400

Cocoa-devListMembers,

In my AppController I have a NSMutableArray which stores all user request/response objects made by the application. The requests are a subclass of NSObject with two NSDictionaries. The first NSDictionary has three key value pairs which comprise the request portion of the root object. I would like to use the objects for each [[rootObject firstDict] objectForKey:@"key1"] for one combobox and the values for [[rootObject firstDict] objectForKey:@"key2"] for another combobox. Finally, as [[rootObject firstDict] objectForKey:@"key3"] is a NSDictionary; I would like to store these objects in a NSTableView. Instead of subclassing NSArray I created a Category!

I am not able to get the Category methods to perform NSLog after setting my data source in the App Controller and reloading data (I'm pretty sure a few of those methods should fire to reloadData). From the below view, is there something I'm missing? Or should I not be using Categories for this purpose (I do understand Categories add these methods to all MutableArrays, but I don't see any negative impact at this point in my app)?

I know my use of code punctuation is not per documentation's example, but it's how i parse it best.

Thanks to all who read this far ;)
Frank

Here is what I have:

//### DPExtra_NSComboBoxDataSource.h
@interface NSMutableArray(DPMutableArrayAdditions)

-(NSString *)comboBox:(NSComboBox *)aComboBox completedString: (NSString *)uncompletedString;
-(NSUInteger)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString;
-(id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex: (NSInteger)index;
-(NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox;
//### End DPExtra_NSComboBoxDataSource.h


//### DPExtra_NSComboBoxDataSource.m
@implementation NSMutableArray(DPMutableArrayAdditions)

-(NSString *)comboBox:(NSComboBox *)aComboBox completedString: (NSString *)uncompletedString{
NSLog(@"comboBox: %@ completedString: %@", aComboBox, uncompletedString);
return [super comboBox:aComboBox completedString:uncompletedString];
}
-(NSUInteger)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString{
NSLog(@"comboBox: %@ indexOfItemWithStringValue: %@", aComboBox, aString);
return [super comboBox:aComboBox indexOfItemWithStringValue:aString];
}
-(id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex: (NSInteger)index{
NSLog(@"comboBox: %@ objectValueForItemAtIndex: %i", aComboBox , index);
return [super comboBox:aComboBox objectValueForItemAtIndex:index];
}
-(NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox{
NSLog(@"numberOfItemsInComboBox: %@", [aComboBox description]);
return [super numberOfItemsInComboBox:aComboBox];
}
//### End DPExtra_NSComboBoxDataSource.m


//### DPAppController.m init
// Create the array to hold all rest requests in cache
// ** recursively release header dicts and restRequests in dealloc
restRequests = [[NSMutableArray alloc] init];

// This is test data in place a cache loading
NSDictionary *firstHeader = [NSDictionary dictionaryWithObjectsAndKeys:@"application/json", @"Accept", @"text", @"Content-type", nil];
DPRestRequest *firstRequest = [[DPRestRequest alloc] initWithUrl:@"http://localhost " andMethod:@"GET" andHeader:firstHeader];

NSDictionary *secondHeader = [NSDictionary dictionaryWithObjectsAndKeys:@"application/json", @"Accept", @"text", @"Content-type", @"cREST/0.1", @"User-Agent", @"Sunday, 01-01-69 00:00:00 EST", @"If-Modified-Since-Date", nil];
DPRestRequest *secondRequest = [[DPRestRequest alloc] initWithUrl:@"http://localhost " andMethod:@"GET" andHeader:secondHeader];
// Add the test data to the array
[restRequests addObject:firstRequest];
[restRequests addObject:secondRequest];
// End init


// -(void)applicationDidFinishLaunching:(NSNotification *)aNotification{
[urlInput setDataSource:restRequests];
[urlInput reloadData];
//### End DPAppController.h


_______________________________________________

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


  • Prev by Date: Initiating a To-many entity
  • Next by Date: Codesign from Buid Server
  • Previous by thread: Re: Initiating a To-many entity
  • Next by thread: Codesign from Buid Server
  • Index(es):
    • Date
    • Thread