Re: NSData confusion

2009-03-20 Thread mm w
on the backside, for this kind of game, sometimes is good to know to use C rather than object/scalar layers, and use only an object to represent the final result. Cheers! On Fri, Mar 20, 2009 at 2:57 PM, Boyd Collier wrote: > In a program I've been developing, I make a lot of use of matrices of

Re: NSData confusion

2009-03-20 Thread Boyd Collier
In a program I've been developing, I make a lot of use of matrices of doubles, and I've written some straight-forward code for doing this that might be of interest to you. If you're interested, I'd be happy to send it to you. Boyd On Mar 20, 2009, at 11:33 AM, James Maxwell wrote: I've

Re: NSData confusion

2009-03-20 Thread James Maxwell
Ah, yes. That makes sense - you're basically finding the row as a kind of offset in the data, is that right? On 20-Mar-09, at 1:00 PM, Stephen J. Butler wrote: On Fri, Mar 20, 2009 at 2:28 PM, James Maxwell wrote: okay, but what about matrices? I've set them up using: float **theMatrix =

Re: NSData confusion

2009-03-20 Thread Stephen J. Butler
On Fri, Mar 20, 2009 at 2:28 PM, James Maxwell wrote: > okay, but what about matrices? > > I've set them up using: > > float **theMatrix = [[self matrixData] mutableBytes]; > > and this part seems okay - or at least, it compiles... But how do I then > access the matrix. > I've been using normal C-

Re: NSData confusion

2009-03-20 Thread James Maxwell
Well, I thought I'd seen it that way, but I can't find it now, so I must have just remembered it incorrectly. At any rate, the best method has been pointed out to me, and I understand why it's the way it is... Any thoughts on accessing a 2D array from an NSMutableData object? J. On 20-Mar-0

Re: NSData confusion

2009-03-20 Thread mmalc Crawford
On Mar 20, 2009, at 11:33 AM, James Maxwell wrote: - (void) setFloatData:(NSData *) theData { if(m_floatData) [m_floatData release]; m_floatData = [theData retain]; } This is how I've seen it done in the Apple docs, but maybe this isn't the best way to do things...(??) I would

Re: NSData confusion

2009-03-20 Thread James Maxwell
okay, but what about matrices? I've set them up using: float **theMatrix = [[self matrixData] mutableBytes]; and this part seems okay - or at least, it compiles... But how do I then access the matrix. I've been using normal C-style array notation, thus far: theMatrix[i][j] = 0.; but th

Re: NSData confusion

2009-03-20 Thread James Maxwell
Oh geez... Of course, NSMutableData... I forgot the m-word. I'll give that a try, and see how it does. cheers, J. On 20-Mar-09, at 11:55 AM, Quincey Morris wrote: On Mar 20, 2009, at 11:33, James Maxwell wrote: I've been using NSData to wrap up float arrays and matrices, so I can pass them

Re: NSData confusion

2009-03-20 Thread James Maxwell
oh... yes... I don't mind Leopard-only, but I haven't wrapped my head around any of the Obj-C 2.0 stuff yet... I'll look into it right away, because I had some thread-related problems earlier today which might be cured by such a move. thanks for that. cheers, J. On 20-Mar-09, at 12:03 PM,

Re: NSData confusion

2009-03-20 Thread Nick Zitzmann
On Mar 20, 2009, at 12:58 PM, James Maxwell wrote: Thanks for the tip on the accessor. I'll rewrite mine... all of them... yikes! ;-) If you don't mind only being able to target Leopard & later, have you tried using the new synthesized accessor feature? That would save you the trouble _

Re: NSData confusion

2009-03-20 Thread James Maxwell
Thanks for the tip on the accessor. I'll rewrite mine... all of them... yikes! ;-) J. On 20-Mar-09, at 11:44 AM, Nick Zitzmann wrote: On Mar 20, 2009, at 12:33 PM, James Maxwell wrote: But this seems like a memory hungry way of doing things (even though setFloatData is a "properly writte

Re: NSData confusion

2009-03-20 Thread Quincey Morris
On Mar 20, 2009, at 11:33, James Maxwell wrote: I've been using NSData to wrap up float arrays and matrices, so I can pass them around my methods and classes. However, I'm finding they're using loads of memory. Now, I do admit this is probably because I'm not doing this properly, so I'd like

Re: NSData confusion

2009-03-20 Thread Nick Zitzmann
On Mar 20, 2009, at 12:33 PM, James Maxwell wrote: But this seems like a memory hungry way of doing things (even though setFloatData is a "properly written" accessor, I think, and does release the current copy "m_floatData" before storing the new one). Is there any way to just operate on t