FROM : Jean-Daniel Dupas
DATE : Sun Jun 08 20:29:01 2008
Le 8 juin 08 à 20:13, Brent Fulgham a écrit :
> I've been enjoying the NSArray/NSMutableArray classes as I work with
> various user interface features for a program I'm working on that
> interacts with a legacy C++ library.
>
> I've recently begun considering how to efficiently display the
> contents of a binary data stream. Currently I'm appending to an
> NSMutableArray of NSNumber objects, which is great for allowing me
> to bind to some UI elements in close to real time and has provided a
> simple and functional mechanism for text numerical display.
>
> Ideally, I'd like to be able to access a raw binary buffer of data
> so I could for example bind it to something like an OpenGL vector
> buffer for display. However, unlike an STL vector, I don't think
> the NS[Mutable]Array provides any guarantees of memory organization,
> nor any way to 'unbox' the NSNumber to deal with the internal values.
>
> For example, in the STL, I could make use of the fact that the
> vector template guarantees the storage to be in contiguous memory
> and accessible as raw double values through the address of the first
> element of the vector. However, I don't think this is possible via
> NSMutableArray and NSNumbers.
>
> Is my only option to periodically sync a buffer of binary double
> values by copying from the NSMutableArray on some periodic basis?
>
> Thanks,
>
> -Brent
AFAK, there is no Cocoa class that fit both Cocoa Binding and raw
stream of data. If you just need Cocoa Binding, NSArray is fine, if
you just want a raw stream for OpenGL, you can use STL vector
(perfectly valid using Obj-C++).
If you need both, you can probably write a small objc Vector class
that wraps a STL vector and implements KVC compliant accessors, so you
will be able to using with Cocoa binding, and access the raw content,
and is just a couple of lines.
see http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html
for details about KVC methods you need.
DATE : Sun Jun 08 20:29:01 2008
Le 8 juin 08 à 20:13, Brent Fulgham a écrit :
> I've been enjoying the NSArray/NSMutableArray classes as I work with
> various user interface features for a program I'm working on that
> interacts with a legacy C++ library.
>
> I've recently begun considering how to efficiently display the
> contents of a binary data stream. Currently I'm appending to an
> NSMutableArray of NSNumber objects, which is great for allowing me
> to bind to some UI elements in close to real time and has provided a
> simple and functional mechanism for text numerical display.
>
> Ideally, I'd like to be able to access a raw binary buffer of data
> so I could for example bind it to something like an OpenGL vector
> buffer for display. However, unlike an STL vector, I don't think
> the NS[Mutable]Array provides any guarantees of memory organization,
> nor any way to 'unbox' the NSNumber to deal with the internal values.
>
> For example, in the STL, I could make use of the fact that the
> vector template guarantees the storage to be in contiguous memory
> and accessible as raw double values through the address of the first
> element of the vector. However, I don't think this is possible via
> NSMutableArray and NSNumbers.
>
> Is my only option to periodically sync a buffer of binary double
> values by copying from the NSMutableArray on some periodic basis?
>
> Thanks,
>
> -Brent
AFAK, there is no Cocoa class that fit both Cocoa Binding and raw
stream of data. If you just need Cocoa Binding, NSArray is fine, if
you just want a raw stream for OpenGL, you can use STL vector
(perfectly valid using Obj-C++).
If you need both, you can probably write a small objc Vector class
that wraps a STL vector and implements KVC compliant accessors, so you
will be able to using with Cocoa binding, and access the raw content,
and is just a couple of lines.
see http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html
for details about KVC methods you need.
| Related mails | Author | Date |
|---|---|---|
| Brent Fulgham | Jun 8, 20:13 | |
| Jean-Daniel Dupas | Jun 8, 20:29 | |
| Joan Lluch (casa) | Jun 8, 20:51 | |
| Jean-Daniel Dupas | Jun 8, 21:56 |






Cocoa mail archive

