Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Dictionary equality problem

Dictionary equality problem
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Mar 29, 2002, 12:13 PM
 
I am having trouble determining if two dictionaries from two different objects contain the same information. Here is the method:

-(void)checkForNewRefs query *)queryToCheck {
query *newQueryResults;
newQueryResults=[self generateQuery:[queryToCheck valueForKey:@"queryTitle"]];
if ([[newQueryResults valueForKey:@"referenceDictionary"] allKeys]==[[queryToCheck valueForKey:@"referenceDictionary"] allKeys]) {
NSLog(@"No new refs");
}
else {
NSLog(@"New refs");
NSLog([newQueryResults valueForKey:@"referenceDictionary"]);
}
}

This is the NSLog output:

2002-03-29 10:08:17.308 CocoaMed[383] New refs
2002-03-29 10:08:17.309 CocoaMed[383] *** -[NSCFDictionary length]: selector not recognized
2002-03-29 10:08:17.322 CocoaMed[383] *** -[NSCFDictionary length]: selector not recognized


I have used the valueForKey calls to retrieve the dictionaries in other methods and they work fine so I don't think that is the problem, but the '[NSCFDictionary length]: selector not recognized' output makes me think otherwise. Any ideas? Am I going about this the wrong way? The dictionaries contain the same keys but the objects are pointers to different objects (but the same info). The method is designed to repeat a search on the internet and then determine if anything has changed (i.e. if newQueryResults has updated compared to queryToCheck).

thanks,
kman
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Mar 29, 2002, 12:24 PM
 
You are basically doing two things wrong here.

== tests for pointer equality. This is unlikely what you want to do here. Instead use [anObj isEqual:anotherObj]
NSLog()'s first argument should be a string. I think you'll probably want to do something like
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>NSLog(<font color = orange>@"new: %@"</font>, [[newQueryResults valueForKey:<font color = orange>@"referenceDictionary"</font>] description]);</font>[/code]

HTH.
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Mar 29, 2002, 01:11 PM
 
Thanks. I have to throw out props to people on this forum. Everyone has been extremely helpful to my learning experience.

thanks,
kman
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:28 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2