Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.mac.programmer.help > #65

Re: dataWithBytesNoCopy:length:freeWhenDone

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From "Silver Dream !" <silverdr@srebrnysen.com>
Newsgroups comp.sys.mac.programmer.help
Subject Re: dataWithBytesNoCopy:length:freeWhenDone
Date Sun, 9 Oct 2011 05:51:25 -0700 (PDT)
Organization http://groups.google.com
Lines 32
Message-ID <16924531.2408.1318164685522.JavaMail.geo-discussion-forums@yqgn17> (permalink)
References <b3d9ee72-a379-4769-9ce9-3ffe843144c9@q25g2000vbx.googlegroups.com> <wcyeo-D8EF3C.13353808102011@news.giganews.com> <707407.1506.1318109321339.JavaMail.geo-discussion-forums@yqar15> <wcyeo-D9850E.16402908102011@news.giganews.com>
Reply-To comp.sys.mac.programmer.help@googlegroups.com
NNTP-Posting-Host 77.8.224.35
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1318165684 21334 127.0.0.1 (9 Oct 2011 13:08:04 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Sun, 9 Oct 2011 13:08:04 +0000 (UTC)
In-Reply-To <wcyeo-D9850E.16402908102011@news.giganews.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=77.8.224.35; posting-account=aItwoAoAAADl77EHHw0OM7wo4ykKlwDL
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.sys.mac.programmer.help:65

Show key headers only | View raw


On Sunday, 9 October 2011 01:40:29 UTC+2, William Yeo  wrote:

> > Basically I need to achieve something similar to lying several structs over 
> > an array of unsigned chars in C. I have an array of bytes (held in a 
> > NSMutableData instance) that I need to parse into distinct objects, 
> > manipulate their contents separately yet have that content remain part of the 
> > original array of bytes. Something like a file containing document that has 
> > its fixed structure. I need to modify elements of this structure and then 
> > write the data back to a file without the need for reconstructing the file 
> > from various elements.

> How about if you write an object which:
> 
> a) takes a filepath (eg) at init
> b) parses the file contents into an NSArray NSMutableData objects, each 
> holding one struct, as you suggest
> c) has methods to apply changes to structs as needed OR
> c) has methods to extract sructs as required
> d) has a method to return an NSData with the fully reconstructed byte 
> string on request
> e) has a method to write the reconstruction back to a filepath
> 
> That way you're creating an object which does YOUR work using an NSArray 
> to maintain the list properly and each component NSMutableData (or you 
> may only need NSData) is being used properly as well.
> 
> You use your object(s) your way, Cocoa uses its object(s) its way.

I think you are right and that seems like a way to go. What I tried to take a shortcut with were the points d, e, and partially b, c. But it seems that I won't escape this. Thank you for your help!

-- 
SD!

Back to comp.sys.mac.programmer.help | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

dataWithBytesNoCopy:length:freeWhenDone "Silver Dream !" <patrycjusz.logiewa@googlemail.com> - 2011-10-07 16:26 -0700
  Re: dataWithBytesNoCopy:length:freeWhenDone William Yeo <wcyeo@shaw.ca> - 2011-10-08 13:35 -0700
    Re: dataWithBytesNoCopy:length:freeWhenDone silverdr@srebrnysen.com - 2011-10-08 14:28 -0700
      Re: dataWithBytesNoCopy:length:freeWhenDone William Yeo <wcyeo@shaw.ca> - 2011-10-08 16:40 -0700
        Re: dataWithBytesNoCopy:length:freeWhenDone "Silver Dream !" <silverdr@srebrnysen.com> - 2011-10-09 05:51 -0700

csiph-web