Когда я alloc
и init
две NSString
переменные и сравниваю их указатели, они одинаковы. Вот фрагмент, который показывает это:
NSString *s1 = [[NSString alloc] initWithString:@"hello world"];
NSString *s2 = [[NSString alloc] initWithString:@"hello world"];
if (s1 == s2) {
NSLog(@"==");
}else {
NSLog(@"!=");
}
Почему s1
и s2
одинаковы?