I have two NSArrays that I'm comparing — in the NSLog output they look identical, yet they don't equal each other somehow. If I convert the NSArray to an NSString I get the same exact result. Comparing them to themselves will be equal. How can I determine why one and two aren't equal? thank you.
- (void)confused:(NSArray *)two {
NSArray *one = [NSArray arrayWithObjects:@"16777223", @"7", nil];
NSArray *two = [[NSBundle bundleWithPath:@"/path/to/bundle"] executableArchitectures];
// NSArray "two" shows as 16277223, 7 in NSLog
if ([two firstObjectCommonWithArray:(NSArray *)one])
{
NSLog(@"- it's equal %@ %@", one, two);
// if array one matches array two then this will output
}
else {
NSLog(@"- it's NOT equal %@ %@", one, two);
}
return;
}
Here's the output from console:
myApp (
16777223,
7
)
myApp (
16777223,
7
)
myApp - it's NOT equal (
16777223,
7
)(
16777223,
7
)
-[NSBundle executableArchitectures]
returns an array of NSNumber
objects, not NSString
objects, so the array you're passing in doesn't have strings in it. If you change
NSArray *one = [NSArray arrayWithObjects:@"16777223",@"7", nil];
to
NSArray *one = [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInteger:NSBundleExecutableArchitectureX86_64],
[NSNumber numberWithUnsignedInteger:NSBundleExecutableArchitectureI386],
nil];
your code should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.