NSMutableDictionary *mdic = [NSMutableDictionary new];
NSNumber *num1 = @(1);
[mdic setObject:@"xxx" forKey:num1];
NSNumber *num2 = [NSNumber numberWithInteger:1];
NSLog(@">>>> test objet is : %@",[mdic objectForKey:num2]);
NSLog(@"num1.hash:%lu,num2.hash:%lu",(unsigned long)num1.hash,(unsigned long)num2.hash);
NSLog(@"num1.pointerValue:%lu,num2.pointerValue:%lu",(unsigned long)num1.pointerValue,(unsigned long)num2.pointerValue);
if(num1==num2){
NSLog(@"num1==num2");
}else{
NSLog(@"num1!=num2");
}
test objet is : xxx
num1.hash:2654435761,num2.hash:2654435761
num1.pointerValue:0,num2.pointerValue:1
num1!=num2
NSMutableDictionary *mdic = [NSMutableDictionary new];
NSNumber *num1 = @(1993);
[mdic setObject:@"xxx" forKey:num1];
NSNumber *num2 = [NSNumber numberWithFloat:1993.0];
NSLog(@">>>> test objet is : %@",[mdic objectForKey:num2]);
NSLog(@"num1.hash:%lu,num2.hash:%lu",(unsigned long)num1.hash,(unsigned long)num2.hash);
NSLog(@"num1.pointerValue:%lu,num2.pointerValue:%lu",(unsigned long)num1.pointerValue,(unsigned long)num2.pointerValue);
if(num1==num2){
NSLog(@"num1==num2");
}else{
NSLog(@"num1!=num2");
}
test objet is : xxx
num1.hash:5290290471673,num2.hash:5290290471673
num1.pointerValue:0,num2.pointerValue:0
num1!=num2
NSMutableDictionary *mdic = [NSMutableDictionary new];
NSNumber *num1 = @(1993);
[mdic setObject:@"xxx" forKey:num1];
NSNumber *num2 = [NSNumber numberWithFloat:1995];
NSLog(@">>>> test objet is : %@",[mdic objectForKey:num2]);
NSLog(@"num1.hash:%lu,num2.hash:%lu",(unsigned long)num1.hash,(unsigned long)num2.hash);
NSLog(@"num1.pointerValue:%lu,num2.pointerValue:%lu",(unsigned long)num1.pointerValue,(unsigned long)num2.pointerValue);
if(num1==num2){
NSLog(@"num1==num2");
}else{
NSLog(@"num1!=num2");
}
test objet is : (null)
num1.hash:5290290471673,num2.hash:5295599343195
num1.pointerValue:0,num2.pointerValue:0
num1!=num2