• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Is it a bad idea to invoke "init..." over and over on the same object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is it a bad idea to invoke "init..." over and over on the same object?


  • Subject: Is it a bad idea to invoke "init..." over and over on the same object?
  • From: Andrei Tchijov <email@hidden>
  • Date: Wed, 2 Nov 2005 09:57:13 -0500

What I am trying to achieve is to have NSData object which wraps IO buffer. For example:
...
int bigIoBufferSize = xxx;
char* bigIoBuffer = (char*) malloc( bigIoBufferSize );
NSData* ioData = [ NSData alloc ];
...
- (NSData*) readData {
...
read data into bigIoBuffer
save number of bytes read in bytesRead
...
return [ ioData initWithBytesNoCopy: bigIoBuffer length: bytesRead ];
}
...
- (void) copyData {
NSData* dataIn = [ self readData ];
[ self writeData: dataIn ];
}
...
So questions are:
1) Is it legal to do initWithBytesNoCopy:length: more then once on the same object?
2) If it is, will NSData just forget about "current" bytes and change internal pointers to point to new one or will it try to free it?


You comments are greatly appreciated,


Andrei Tchijov Leaping Bytes, LLC

     web: www.leapingbytes.com
   email: email@hidden
      AIM: leapingbytes
Google: email@hidden
      ICQ: 151229319




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Is it a bad idea to invoke "init..." over and over on the same object?
      • From: Andreas Mayer <email@hidden>
    • Re: Is it a bad idea to invoke "init..." over and over on the same object?
      • From: Jack Nutting <email@hidden>
    • Re: Is it a bad idea to invoke "init..." over and over on the same object?
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: RE: How to get the Image From QCView
  • Next by Date: Re: Is it a bad idea to invoke "init..." over and over on the same object?
  • Previous by thread: Getting the pixel-coördinates
  • Next by thread: Re: Is it a bad idea to invoke "init..." over and over on the same object?
  • Index(es):
    • Date
    • Thread