簡體   English   中英

相當於Java Vector的Objective-C?

[英]Objective-C equivalent of Java Vector?

在Objective-C中,Java的Vector相當於什么?

嘗試使用NSMutableArray。

您將發現的最接近的東西是NSMutableArray,與Java Vector相反,它是線程安全的execpt。 如果您不需要線程安全,則NSMutableArray很好。 我懷疑如果使用java vector而不是List,那是因為需要線程安全,那么在Objective-C中,您可能應該使用NSArray。 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM