|
|
#1 |
|
Mutable dictionary issue
HI everybody i have an issue and couldn't able to solve it .so,any help from u guys would be really helpfull.issue is
i am having a Mutabledictionary in the format of Bank id 2 kd 4 gd 5 gang id 4 kd 8 gd 1 like this and another dictionary in the format of Bank gd gang kd like that i need to comare this dictionary with the above one and retrieve their corresponding values .i have tried this code but it is giving error Code:
int count = [mFavoritesArray count];
for (NSMutableDictionary *dd in mTest) {
for (int i=0; i < count; i++) {
NSMutableDictionary *tmp = [dd valueForKey:[mFavoritesArray objectAtIndex:i]];
Last edited by robbieduncan; Aug 24, 2011 at 04:18 AM. Reason: Please use the code tags, thanks |
|
|
|
0
|
|
|
#2 |
|
valueForKey: is part of KVC system. You should not be using that for this purpose. You should be using objectForKey:.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#3 | |
|
Quote:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString objectForKey:]: unrecognized selector sent to instance |
||
|
|
0
|
|
|
#4 |
|
Then you have a memory management problem as you are sending the message to a string, not a dictionary.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#5 |
|
yes u r right when i print dd dictionary it is having a single elment only .so could u tell me how to implement for each loop with dd dictionary and where i am doing wrong
|
|
|
|
0
|
|
|
#6 |
|
What is mTest?
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#7 |
|
is a Dictionary and another issue is hi guys i am trying to read plist which is inthe form of Bug dictionary key value key value hint dictionary z value d value like this when i tried to read it using NSMutable dictionary it is reading properly but when i tried to read it using NSArray it is not reading the contents and code i am using are NSString *mm=[[NSBundle mainBundle] pathForResource:@"Score" ofType:@"plist"]; NSArray *mTest=[[NSArray alloc] initWithContentsOfFile:mm];// here it is not working NSString *mm=[[NSBundle mainBundle] pathForResource:@"Score" ofType:@"plist"]; NSMutable dictionary *mTest=[[NSMutableDictionary alloc] initWithContentsOfFile:mm];// here it is working the reason why i am trying to use NSarray is in apple periodic elements example it is working but it is not working in my code any suggestion are welcome |
|
|
|
0
|
|
|
#8 |
|
So what does iteration over a dictionary do? Hint it doesn't iterate over the values alone.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#9 | |
|
Quote:
id 2 kd 4 gd 5 gang dictionary id 4 kd 8 gd 1 like this and another dictionary in the format of Bank gd gang kd i need to compare these two dictionaries and add all values the code i am using is and for adding i dont know how to that any code from you will be a great helpfull to me NSString *mm=[[NSBundle mainBundle] pathForResource:@"Score" ofType:@"plist"]; NSMutableDictionary *mTest=[[NSMutableDictionary alloc] initWithContentsOfFile:mm]; NSArray *aa=[mTest mutableCopy]; for (NSDictionary *dd in aa)// here dd is not able to retrieve data { for (int i=0; i < count; i++) { NSMutableDictionary *tmp = [dd valueForKey:[mFavoritesArray objectAtIndex:i]]; } } Last edited by ghousemd; Aug 25, 2011 at 07:04 AM. |
||
|
|
0
|
|
|
#10 |
|
So if you want the values what options do you have? Can you get an array of values from a dictionary? What does the documentation have to say on this.
Honestly I feel like I am having to excessively spoon feed you answers. The ability to read and understand the documentation is a core programming skill that I suggest you need to work on.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#11 |
|
[QUOTE=robbieduncan;13242891]So if you want the values what options do you have? Can you get an array of values from a dictionary? What does the documentation have to say on this.
Bank dictionary id 2 kd 4 gd 5 gang dictionary id 4 kd 8 gd 1 like this and another dictionary in the format of Bank gd gang kd getting all values and adding i know about it but here i need to extract only values which are in second dictionary and need to add it for example in second dictionary i am having gd and kd i need to use that and get there corresponding values and add it which i dont know |
|
|
|
0
|
|
|
#12 |
|
You ignored my question completely. I am not going to continue this. Look at the documentation for a method that will return an array of values from a dictionary. You seem to expect someone else to write your code for you. That is not programming. It's just utter laziness.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
1
|
|
|
#13 |
|
Code:
for (NSDictionary *dd in aa)// here dd is not able to retrieve data
{
for (int i=0; i < count; i++) {
NSMutableDictionary *tmp = [dd valueForKey:[mFavoritesArray objectAtIndex:i]];
}
You said mTest is an NSMutableDictionary. So, for each dd, NSMutableDictionary, in mTest you want the following code inside the loop to execute? Does mTest contain NSMutableDictionaries? Is it unable to retrieve data or is it trying to retrieve the wrong type of data you are looking for? |
|
|
|
0
|
|
|
#14 | ||
|
Quote:
mTest contain NSMutabaleDictionaries and it is retrieveing data and dd it should retrieve each dictionary from it but it is not working i found solution for my problem code is for (id key in mTest) { NSLog(@"%@",key); id value = [mTest objectForKey:key]; id vv=[mFinalDictionary valueForKey:key]; id gg=[value valueForKey:vv]; NSLog(@"%@",value); NSLog(@"%@",vv); NSLog(@"%@",gg); } ---------- ---------- Quote:
|
|||
|
|
0
|
![]() |
|
| Tags |
| xcode |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Adding a dictionary to Dictionary app | Sarsay | Mac Applications and Mac App Store | 2 | Oct 23, 2012 03:18 PM |
| Is Bento 4 a good database software for making a dictionary? | MJNBGA | Mac Applications and Mac App Store | 3 | Aug 1, 2012 11:14 PM |
| [UPDATE] New Oxford American Dictionary 2.0 missing "The Right Word section." | IntelliUser | iPhone and iPod touch Apps | 2 | Nov 15, 2010 01:33 PM |
| ms office 2008 on mac dictionary issue | guust | Mac Applications and Mac App Store | 0 | Sep 9, 2010 10:07 AM |
| Microsoft Word For Mac 08 Dictionary Issue | kluckste | Mac Applications and Mac App Store | 0 | Nov 2, 2009 07:18 PM |
All times are GMT -5. The time now is 01:23 PM.








Linear Mode

