The output of the code below is,
areEqual
areEqual
Can somebody explain why?
NSString *firstUserName = @"nick";
NSString *secondUserName = @"nick";
if (firstUserName == secondUserName)
{
NSLog(@"areEqual");
}
else
{
NSLog(@"areNotEqual");
}
MyObject *object1 = [[MyObject alloc]init];
object1.identifier = @"1";
MyObject *object2 = [[MyObject alloc]init];
object2.identifier = @"1";
if (object2.identifier == object1.identifier)
{
NSLog(@"areEqual");
}
else
{
NSLog(@"areNotEqual");
}