gnasher729
Yes thats what I wanted to do and have decided I will stick with that method, see posing #3
Back in the day I was one of the programmers who wrote
http://en.wikipedia.org/wiki/Pushover_(video_game)
and as an exercise I thought I would try to write it for the apple mac ( iPhone ? ). It was originally wrote in "C" ( not really done in those days ) and assembly.
So that data that is in the arrays is the puzzle data consisting (byte) background, (byte) Platform Overlay, (byte) Domino and (byte) ladder.
These are pointers to graphics that need to be masked with each other to create the background. ( layers ).
There are 20 blocks across and 15 blocks down hence 300 integers per puzzle and 100 puzzles.
Hope that answers your and Lee's questions.
No doubt I will have more question as I get stuck with my project I will be posting here as the people are very kind and friendly.
PS ( Gnasher ) I like reading the Dandy/Beano when I was a kid.
It seems to me (though I may misunderstand the architecture) that you only need to have one "level" at a time loaded in memory. This changes the amount of overhead that would be necessary to store these values in objects by a large margin. It may still be simpler for you to just keep these in C style int arrays, but having an NSArray of 300 NSNumber objects is a lot less overhead than 30,000. You're spending 1204 or 1208 bytes now for 300 ints and one int pointer(which may be 4 or 8 bytes). I can't say how big (or if it's even the same instance to instance) an NSNumber is, but you'd be looking at:
4 or 8 bytes for your NSArray *
The size of the backing store for the NSArray and other Object overhead. I have no idea what this is, but since it is immutable it's probably just a regular C-style array, so this would probably just be a NSObject *, so again 4 or 8 bytes for the backing store, plus an unknown (to me at least) Object overhead.
300 NSNumber *s, 4 or 8 bytes each, so either 1200 or 2400 bytes here
300 NSNumber Objects. I have no idea how big these are. I think the backing store would only be 8 bytes at most, because the largest values it can take are doubles and long longs. So that's 2400 bytes, plus Object overhead. This is a shot in the dark.
So this gives us:
4 or 8
+
4 or 8 + N (NSArray overhead)
+
1200 or 2400
+
2400 + 300 M(NSNumber overhead)
So being modest and saying that the NSArray and NSNumber overhead is 32 bytes, that gives us:
13,240 bytes on a system with 32-bit pointers
or
14,448 bytes on a system with 64-bit pointers
This is about an 11-12x increase in memory, and probably somewhat of a hit in setting it up (about 0 with int arrays, since you have them in your data section already, and you're just assigning a pointer, versus 300 NSNumber initializations, and one NSArray initialization).
In this particular case it sounds like you get no real benefit from having an NSArray, since you know the exact length of the array all the time already, etc.
On a separate note, you will have to be careful about getting your individual bytes out of your ints. I would actually say to just have 4 different character arrays that store your data, rather than 1 int array. I don't know if you plan to support x86, PPC, and ARM, but PPC is big-endian and x86 and the ARM in the iPhone are little-endian. This will make getting your bytes out of your int a more difficult task, if you're going to support both. If you had 4 character arrays, it would be a lot easier to handle. Just a thought.
-Lee