help-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mistake


From: reuss
Subject: mistake
Date: Tue, 01 Jul 2003 11:20:08 GMT
User-agent: Pan/0.11.2 (Unix)

it is a mistake, sorry
On Tue, 01 Jul 2003 11:58:16 +0200, reuss wrote:

> I have an NSDictionary as follows (keys + array as object):
> 
> {
> aKey = (
>       anObject
> );
> otherKey = (
>       "other Object",
>       "third Object",
>       "second Object"
> );
> }
> 
> I have a method too:
> 
> - (NSMutableDictionary *) findStringInKeys: (NSString *) aString
>         {
>         unsigned int counter;
>         unsigned int i;
>         NSRange myRange;
> 
>         NSArray *records = [myDict allKeys];
>         NSMutableDictionary *match = [NSMutableDictionary new];
>       counter = [records count];
>         for (i=0; i<counter; i++)
>                 {
>                 myRange = [[records objectAtIndex:i] rangeOfString:
>                 aString];
>                        if (myRange.length != 0)
>                         {
>                         NSLog (@"%@", [myDict objectForKey: [records
>                         objectAtIndex: i]]); }
>                 }
>         return match;
> }
> 
> If I convoque my method in main.m as follows: [myDico findStringInKeys:
> @"aKey"];
> 
> I get
> Jul 01 11:53:18 dix[2122] ("anObject","anObject") or [myDico
> findStringInKeys: @"otherKey"]; Jul 01 11:53:18 dix[2122] ("other
> Object","third Object", "second Object", "other Object","third Object",
> "second Object" )
> 
> As I can see, every arraymembers are duplicated (with -count, i got two
> for an array of 1 member), but I don't see why. Is it normal?
> 
> What is wrong?
> thanks in advance


reply via email to

[Prev in Thread] Current Thread [Next in Thread]