help-gnustep
[Top][All Lists]
Advanced

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

my array return every members twice


From: reuss
Subject: my array return every members twice
Date: Tue, 01 Jul 2003 09:58:16 GMT
User-agent: Pan/0.11.2 (Unix)

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]