iphone - NSMutableArray -removeObject : also remove a NSString if it has a different memory adress? 会吗

标签 iphone cocoa-touch uikit nsarray

示例:我将一些 NSString 对象添加到 NSMutableArray:@"Foo"、@"Bar"、@“FooBar"。现在,我在其他地方再次访问该数组,并且想要删除 @"Foo"。因此,我创建了一个新的 NSString @"Foo",并将其传递给 -removeObject:。文档没有说明 -removeObject 的工作标准。我认为它只查找内存地址,所以在这种情况下它什么也不做。是这样吗?正确吗?

最佳答案

根据removeObject的文档:“匹配是根据对象对isEqual:消息的响应来确定的”,并将字符串与哈希值进行比较(“如果两个对象相等,则它们必须具有相同的哈希值”)所以,是的,这应该是不正确的。

关于iphone - NSMutableArray -removeObject : also remove a NSString if it has a different memory adress? 会吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1310848/

相关文章:

iphone - iOS :Sending Facebook Request

iphone - 如果主机在 2-3 秒内没有响应,则设置超时

ios - 无法从字符串创建我的 UIImageView 类

cocoa-touch - 如何移动 UIAlertView 中的按钮以为插入的 UITextField 腾出空间?

iphone - UIAlert按钮大小

ios - UISearchController:searchBar 和 scopeBar 在第一次触摸事件时重叠

ios - 如何处理 UICollectionView 中的后台点击

iphone - tableView 的 commitEditingStyle 并知道何时点击 'Done' 按钮

iphone - 如何给按钮设置标签?

ios - 为什么标签的高度为零?