Re: Copying Notification Dictonaries & sortingUsingSelector problems
Re: Copying Notification Dictonaries & sortingUsingSelector problems
- Subject: Re: Copying Notification Dictonaries & sortingUsingSelector problems
- From: <email@hidden>
- Date: Wed, 26 Jun 2002 17:58:44 +0200
- Thread-topic: Re: Copying Notification Dictonaries & sortingUsingSelector problems
My god, these people at our IT department... First my original email got send twice for some mysterious reason, for which I deeply appologize. Next, the emailserver has been out of business (guess what brand of OS it runs) the whole day, and now they simply leave because it's 5 o'clock. Then I thought to reply via another email account, but I got a reply from the list moderator that I was not a member, so sorry for the late reply after you responded so quick John...
I wrote:
>
> But when I run the program the following message is logged:
>
>
>
> -[NSCalendarDate sortExperiments:]: selector not recognized
You answered:
>
The obvious problem is that you're sending the -sortExperiments:
>
message to a date, not to the array of experimentKeys.
I figured that, but I don't get it, because I'm 100% sure that experimentKeys is an array, containing NSCalendarDates. So I what I thought was that the sortExperiments method is triggered with as it's argument the NSCalendarDates derived from the array. Why then, as the sortExperiment: function takes an NSCalendarDate, doesn't it work? What would be the best approach to let me sort the experiments on their property stopdate. To summarize, I have the following situation:
NSArray experimentKeys: startdate Experiment1, startdate Experiment2 etc.
Sort this array by:
1 retrieving startdates, use these keys to look up the corresponding experiment objects from the experimentsDict dictionary.
2 ask these objects for their stopdate
3 sort the array by asking the objects their stopdate
Many thanks in advance!
Alex
>
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.