4

I'm trying to loop through an array (compare Addr), and find the matching Strings (currentAddr) and trying to put only the matvched Strings into another array but i keep getting an error

"No visible @Interface for NSArray declares the selector addObject"

NSArray *matchedAddr;
//NOTE: multiple addresses from compareAddr[i] may match to multiple stored Addresses
for (NSUInteger i = 0; i < [compareAddr count]; i++)
{
    //Checking IF the obtained key (Mac Address) at compareAddr[i] matches one of the stored Addresses
    NSString *currentAddr = [compareAddr objectAtIndex:i];
    BOOL addrExists = ([[dictionaryOfAddresses     objectForKey:@"StoredAddr"]objectForKey:currentAddr] != nil);

    if (addrExists)
    {   
        NSLog (@"Match found at index %1u", i);
        [matchedAddr addObject:currentAddr];
    }

    else { NSLog(@"No Value matches at index %i \n", i); }
}
NSLog (@"Array of matched addresses for further processing %@", matchedAddr);

1 Answer 1

15

Define it as mutable

NSMutableArray *matchedAddr=[[NSMutableArray alloc]init];
Sign up to request clarification or add additional context in comments.

3 Comments

Should also note that NSArray and NSMutableArray are implemented separately to allow for usage of the less resource intensive NSArray when possible.
Also note that he needs to alloc/init the NSMutableArray before trying to add objects to it.
when i print my array it prints null ! ! !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.