• 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
Copying Notification Dictonaries & sortingUsingSelector problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Copying Notification Dictonaries & sortingUsingSelector problems


  • Subject: Copying Notification Dictonaries & sortingUsingSelector problems
  • From: <email@hidden>
  • Date: Tue, 25 Jun 2002 19:49:56 +0200
  • Thread-topic: Copying Notification Dictonaries & sortingUsingSelector problems

Hi everybody,

I'd like to start by thanking everyone who helped me with my "inter object messaging problem". Although I realize that I should try to think of a better MVC implementation for my next app ;-), I resorted to using notification and this works perfectly. Still I wonder, do I have to use the "copy" command like in my code below, or is it unnecessary and therefor unwanted? Allong with the notification I send along a dictionary with some properties of my "experiments". In the following way I "copy" this dictionary to one within the receiving controller object:

In the init method:
dockMenuItemsExperiments = [[NSMutableDictionary alloc] init];

- (void)updateDockItemsExperiments: (NSNotification *)note{
dockMenuItemsExperiments = [[note object] copy]; // copies the dictionary
[self updateDockMenu]; // a method to update my dockmenu
}

Is this the correct way, or could I just say: dockMenuItemsExperiments = [note object]; ? Or doesn't it matter as long as I dealloc the dockMenuItemsExperiments dictionary when I do not longer need it?

Then finally I have one other problem I can't overcome without help.
In my program I track a number of laboratory experiments via an experiment object for each one. This object I instantiate with a "startdate", "time" and "stopdate" variable. All the experiment objects are stored in "experimentDict", a mutable dictionary with the startdate as it's key. At the same time this startdate is stored in an array that serves the tableview with data. So as a result my tableview shows all experiments, but I would like to sort the experiments by there stopdates. Sorting their startdates is easy, as I only have to sort the array. But now sorting by stopdate, a property of each experiment. I thought of using :

[experimentKeys sortUsingSelector: @selector(sortExperiments:)];

// experimentKeys is the array containing the keys to retreive the objects from
// the experimentDict

Later on I done have the sort function:

- (NSComparisonResult)sortExperiments: (NSCalendarDate*) startdate{
Experiment* exp1; // first experiment object
Experiment* exp2; // second experiment object

exp1 = [experimentDict objectForKey: self];
exp2 = [experimentDict objectForKey: startdate];

if ([[[exp1 stopdate] laterDate: [exp2 stopdate]] isEqualToDate:
[exp2 stopdate]]){
return NSOrderedAscending;
}
else if ([[[exp1 stopdate] laterDate: [exp2 stopdate]] isEqualToDate:
[exp1 stopdate]]){
return NSOrderedDescending;
}
else{
return NSOrderedSame;
}

}

But when I run the program the following message is logged:

-[NSCalendarDate sortExperiments:]: selector not recognized

Could anyone help me to sort my data?? Any help, comments and suggestions are appreciated enormously!

Alex
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Copying Notification Dictonaries & sortingUsingSelector problems
      • From: Charles Jolley <email@hidden>
    • Re: Copying Notification Dictonaries & sortingUsingSelector problems
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: ICA Image Capture Architecture Information
  • Next by Date: Re: Escaping spaces in paths
  • Previous by thread: ICA Image Capture Architecture Information
  • Next by thread: Re: Copying Notification Dictonaries & sortingUsingSelector problems
  • Index(es):
    • Date
    • Thread