PDA

View Full Version : How do We Express an Array or Collections of Objects?




teguh123
Mar 31, 2011, 09:39 PM
NSArray?

Is there a better class?

For example, in vb.net I have generic.list(of SomeClass), which I believe is better than just SomeClass(). However both are easily interchangeable due to linq .toList and .toArray function.



Nayefc
Mar 31, 2011, 09:53 PM
What do you mean by a "better" way?

In Objective-C, we use NSArray class to create arrays.

chown33
Mar 31, 2011, 09:57 PM
Collections Programming Topics: Arrays: Ordered Collections (http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Collections/Articles/Arrays.html%23//apple_ref/doc/uid/20000132-BBCCJBIF)

Objective-C doesn't have generics.

KnightWRX
Apr 1, 2011, 06:07 AM
What are you trying to accomplish exactly ? Maybe if you grounded your question in something more tangible than comparing languages, we could help you with the NeXTSTEP/Cocoa Touch/Objective-C answer.

As it stands, NSArray or NSMutableArray are it for "lists of objects".

Sykte
Apr 1, 2011, 06:50 AM
NSArray?

Is there a better class?

For example, in vb.net I have generic.list(of SomeClass), which I believe is better than just SomeClass(). However both are easily interchangeable due to linq .toList and .toArray function.

NSArray & NSMutableArray holds objects not data types so unlike VB its does not require multiple array types.

In VB you define a generic to hold multiple data types at one time otherwise a list would be restricted to only one type at a time ie: string, int, custom object.