I'm new to objective-C programming and I have a few questions.
What is the proper way to create a dynamically typed array? I want objects that have an array member whose type is decided at the time of initialization of the object.
I'm used to being able to do this in C++ with template parameters: Vector<float, 3> obj; (actually this decides it at compile time, but the point is that I don't have to write a bunch of different vector classes; in Objective-C this is avoided by the dynamic run-time typing and I don't know how to take advantage of it in this case)
I'm using an NSMutableArray right now, but it requires objects, not objCTypes like int, float, etc. So, I have to go through the NSNumber object to add the elements to the array. Then, when I want to retrieve the elements, I want to retrieve them in the non-object type that the object was instantiated with (int, float, etc.), but I don't know how to record the underlying type to which they should be cast back to. Am I missing something? Am I thinking too much like c++? What is the proper solution to this problem?
Thanks,
Sancho
What is the proper way to create a dynamically typed array? I want objects that have an array member whose type is decided at the time of initialization of the object.
I'm used to being able to do this in C++ with template parameters: Vector<float, 3> obj; (actually this decides it at compile time, but the point is that I don't have to write a bunch of different vector classes; in Objective-C this is avoided by the dynamic run-time typing and I don't know how to take advantage of it in this case)
I'm using an NSMutableArray right now, but it requires objects, not objCTypes like int, float, etc. So, I have to go through the NSNumber object to add the elements to the array. Then, when I want to retrieve the elements, I want to retrieve them in the non-object type that the object was instantiated with (int, float, etc.), but I don't know how to record the underlying type to which they should be cast back to. Am I missing something? Am I thinking too much like c++? What is the proper solution to this problem?
Thanks,
Sancho