我正在尝试遍历一个数组(比较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);
答案 0 :(得分:16)
将其定义为可变
NSMutableArray *matchedAddr=[[NSMutableArray alloc]init];