discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSIternalInconsistencyException with NSMutableData


From: Germán Arias
Subject: NSIternalInconsistencyException with NSMutableData
Date: Fri, 03 Jan 2014 23:27:23 -0600
User-agent: GNUMail (Version 1.2.1)

Hi,

I'm having a problem with NSMutableData at GNUMail. This app declares 
extensions for NSData at file NSData+Extension.m, inside these methods 
NSMutableData objects are used. Specifically the methos 
-replaceBytesInRange:withBytes:length:, which causes an 
NSIternalInconsistencyException with message: missing bytes in 
replaceByteInRange:withBytes:. I thought this was because the object 
NSMutableData was modified before call -replaceByteInRange:withBytes:. So, I 
changed this and to now the bytes are removed with -setLength:, which works for 
me. But after re-read the documentation, I see I misunderstand this, and that 
-replaceBytesInRange:withBytes:length: should work.

The correspondign code is, the exceptions occurs at last line:

       // The line is fixed, we append it.
          [lines appendData: aLine];
          
          // We add the necessary quote characters in the paragraph
          if (quote_depth)
            {
              NSData *d;
              
              d = [lines quoteWithLevel: quote_depth   wrappingLimit: 
theQuoteLimit];
              [lines replaceBytesInRange: NSMakeRange(0, [lines length])
                     withBytes: [d bytes]  length: [d length]];
            }

          // We append the paragraph (if any)
          if ([lines length])
            {
              [aMutableData appendData: lines];
            }
          [aMutableData appendCString: "\n"];
          
          // We empty the paragraph buffer
          [lines replaceBytesInRange: NSMakeRange(0, [lines length] withBytes: 
NULL  length: 0];


Any advice?

Thanks.
Germán.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]