4

我正在尝试遍历一个数组(比较 Addr),并找到匹配的字符串(currentAddr)并尝试仅将匹配的字符串放入另一个数组中,但我一直收到错误消息

“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);
4

1 回答 1

15

将其定义为可变的

NSMutableArray *matchedAddr=[[NSMutableArray alloc]init];
于 2012-10-01T09:51:14.277 回答