简体   繁体   English

相当于Java Vector的Objective-C?

[英]Objective-C equivalent of Java Vector?

在Objective-C中,Java的Vector相当于什么?

尝试使用NSMutableArray。

The closest thing you will find is NSMutableArray, execpt that contrary to java Vector, it is not thread safe. 您将发现的最接近的东西是NSMutableArray,与Java Vector相反,它是线程安全的execpt。 If you do not need thread safety, NSMutableArray is nice. 如果您不需要线程安全,则NSMutableArray很好。 I suspect that if you use java vector instead of List, it is that you need thread safaty, then in objective-C, you should probably use NSArray. 我怀疑如果使用java vector而不是List,那是因为需要线程安全,那么在Objective-C中,您可能应该使用NSArray。 THe API is slightly different, since the add operation of an element to a NSArray returns a new array instance, but it is thread safe, see http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html API稍有不同,因为将元素添加到NSArray会返回一个新的数组实例,但是它是线程安全的,请参阅http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading /ThreadSafetySummary/ThreadSafetySummary.html

NSArray: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/cl/NSArray NSMutableArray: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMutableArray NSArray: http : //developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/cl/NSArray NSMutableArray: http : //developer.apple .com / mac / library / documentation / Cocoa / Reference / Foundation / Classes / NSMutableArray_Class / Reference / Reference.html#// apple_ref / occ / cl / NSMutableArray

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM