Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
My primarily background is the .NET enviornment... so please excuse me if I am not using the right term here.

In .NET, I could strongly type my arrays.

Example:
Instead of: Dim myObjects() as Object;
I could do: Dim myCarObjects() as Car;

This would give me enhanced supported in the development enviornment, directly from the array and I didn't have to CAST or connect the specific object to a specific defined object...

In my iPhone code so far, I have been using NSArray to hold my custom class objects, and then either defining a holding object of the specific type.. or casting it... primarily to avoid Compiler warning messages (as I don't like having any warnings, as a warning could be an error).

So instead of:
NSArray *_myObjects;
Is there a way to do
Car *_myCars(); or something like that (not sure how to express that since Car *_myCar is a singular definition).

I hope that made sense.
 
Now that I typed that first message, and idea just popped into my head.

For each of my custom classes (that inherit from NSObject), do I have to build a custom class array (that inherits from NSArray) ?

If so, any good examples of doing that so that it is type specific and not just a new name for NSArray.
 
The point is, the "objective" side is decent. The "C" side sucks. like always do.

Dark day was the day that C was chosee as the standar.... how much time wasted!
 
So from those replies, I am guessing I am stuck doing something like this:

NSArray *_myCars = [self.functionToBuildMyCars];
Car *wrkCar = [_myCars objectAtIndex:x];
[wkrCar startCar];

Instead of
[[_myCars objectAtIndex:x] startCar];

And not get any warnings (as I have been bit at times, and took a long time to debug when I ignore warnings)..

Oh well... worth a shot at asking... (also on larger classes, it is nice to have the prompting for method names).
 
Or

Code:
[((Car *) [_myCars objectAtIndex:x]) startCar];

Oh and a matter of style: class names should be in start with a capital letter.
 
Or

Code:
[((wrkCar *) [_myCars objectAtIndex:x]) startCar];

Oh and a matter of style: class names should be in start with a capital letter.

;)

wrkCar was my temporary object/variable.
Car was my custom class... ;)

Good reminder though on the uppercase.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.