Note that there are some explanatory texts on larger screens.

plurals
  1. POreading binary data (rtf) to string
    text
    copied!<p>I've been working on a core data program for a while now. I'm trying to combine attributes of an entity in a text view for saving to PDF and Printing. One of the attributes of the entity uses binary data. </p> <p>When I execute this: </p> <p><code>NSData *myData = [object valueForKey:@"cueNotes"];</code></p> <p>...it returns this:</p> <pre><code> typedstreamè@ NSMutableDataNSDataNSObjecti[276c]{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf540 {\fonttbl\f0\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \f0\fs20 \cf0 step one text} </code></pre> <p>when I try this: </p> <pre><code>NSAttributedString* myDataTry = [[[NSAttributedString alloc] initWithRTF:myData documentAttributes:nil] autorelease]; </code></pre> <p>... myDataTry is nil. I read a little about the rtf format and then removed this: </p> <pre><code>typedstreamè@ NSMutableDataNSDataNSObjecti[276c] </code></pre> <p>...from the myData data but still get a nil result. Does anyone have any idea what I'm doing wrong?</p> <p>Update: After thinking about the first answer I tried this (as well as a couple permutations):</p> <pre><code>NSString* notesString = [[[NSString alloc] initWithRTF:[object valueForKey:@"cueNotes"] documentAttributes:nil] autorelease]; </code></pre> <p>as well as an allocated string and still no results.</p> <p>Here is the results of the entity that I'm pulling from:</p> <pre><code>2010-10-30 00:47:32.867 lzshow7.2[4222:10b] &lt;NSManagedObject: 0x2a4850&gt; (entity: Song; id: 0x26a030 &lt;x-coredata:///Song/t172F066B-285C-4125-B2FA-CFFA6A353D102&gt; ; data: { cueName = Stupid; cueNo = 001; cueNotes = &lt;040b7479 70656473 74726561 6d8103e8 84014084 84840d4e 534d7574 61626c65 44617461 00848406 4e534461 74610084 8408&gt;; songToEffect = ( ); songToInstrument = ( ); </code></pre> <p>})</p>
 

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