Objective-C:在for循环中向NSArray添加对象

Tas*_*que 4 loops objective-c nsarray

我正在尝试循环一个数组(比较Addr),找到匹配的字符串(currentAddr),并尝试只将matvched字符串放入另一个数组但我不断收到错误

"NSArray没有可见的@Interface声明选择器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);
Run Code Online (Sandbox Code Playgroud)

Neo*_*Neo 15

将其定义为可变的

NSMutableArray *matchedAddr=[[NSMutableArray alloc]init];
Run Code Online (Sandbox Code Playgroud)