Note that there are some explanatory texts on larger screens.

plurals
  1. POAm I misusing NSString/NSMutableString with my Core Data model?
    primarykey
    data
    text
    <p>I'm looping through the results of a fetch request against a Core Data store. For each object in the result list, I am reading several attributes of type string and concatenating them into one string (to be output as a CSV format file).</p> <p>One particular string of one particular record in my dataset is giving me trouble: extraneous characters (kanji, arabic, etc.) are appended to the end of the string, it does not append properly to my result string, and my CSV file format is hosed.</p> <p>Here is my code for looping through the fetch results and appending the string:</p> <blockquote> <pre><code>NSMutableString *reportString = [[NSMutableString stringWithFormat:@"...\n"]; for (int s = 0; s &lt; [frc.sections count]; s++) { for (int r = 0; r &lt; [[frc.sections objectAtIndex:s] numberOfObjects]; r++) { NSIndexPath *i = [NSIndexPath indexPathForRow:r inSection:s]; Thread *thread = [frc objectAtIndexPath:i]; NSMutableString *activity = [NSMutableString stringWithString:[thread activity]]; . . . [reportString appendString:activity]; [reportString appendFormat:@",%@\n", client]; } } </code></pre> </blockquote> <p>I'm using <em>stringWithString</em> here, but I've also used several other string methods with similar, corrupted, results. One time, Arabic letters appeared. Another time, it was <strong>"...random...FSO_CARRIER_ATT@2X.png"</strong>. I've also tried using a separate fetch results array (instead of a fetched results controller).</p> <p><img src="https://i.stack.imgur.com/PBVY4.png" alt="&quot;Corrupted&quot; String"></p> <p>One weird thing is that when I do a <strong>PO</strong> from lldb, the string shows up correctly. This may explain why this "corruption" doesn't show up on my table views, just when I am trying to mash strings together.</p> <h2>My Question</h2> <p>Am I copying the string values from the Core Data model incorrectly and causing this to happen? Is there a technique I am missing out on?</p> <h2>Update:</h2> <p>A screenshot of the watched variable versus an NSLog of the value:</p> <p><img src="https://i.stack.imgur.com/Jeuul.png" alt="screnshot 2"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload