Skip navigation.
 
mlRe: App-specific URLs and the pasteboard. Need help.
FROM : Alastair Houghton
DATE : Sat Jan 19 00:30:33 2008

On 18 Jan 2008, at 20:17, Duncan Champney wrote:

> I'm not sure I'm reading the documentation correctly, however. 
> Here's the code I'm trying to use:
>
>        NSString* theURLName = [NSString stringWithFormat: 
> NSLocalizedString(@FW_URL_PREFIX ,nil), theDocumentName];
>
>        theFW_URL = [NSURL URLWithString:theURLString];
>
>      //Create an NSAttributedString to hold the RTF description of 
> the URL.
>      theRTF_string= [[NSAttributedString alloc] initWithString: 
> theURLName];
>      theStringRange.location = 0;
>        theStringRange.length = [theURLName length];
>        theAttributesDict =
>            [NSDictionary  dictionaryWithObjects:[NSArray 
> arrayWithObjects: theFW_URL, nil]
>                forKeys: [NSArray 
> arrayWithObjects:NSLinkAttributeName, nil]
>            ];
>      NSData* the_RTF_data = [theRTF_string RTFFromRange: 
> theStringRange documentAttributes:theAttributesDict];


No, that's not right. The attributes need to be set in the attributed 
string. The document attributes are something else entirely (more 
specifically, they contain information about the *document*, not text 
attributes which is what NSLinkAttributeName is). You probably want to 
do -initWithString:attributes: rather than just -initWithString:, then 
pass nil for the documentAttributes: argument.

Also, consider using -dictionaryWithObjectsAndKeys: or -
dictionaryWithObject:forKey: rather than -
dictionaryWithObjects:forKeys:.  They're more efficient and involve 
less typing too :-)

Kind regards,

Alastair.

p.s. Please copy the list on replies; that way others with similar 
questions will be able to find the answers they need.

--
http://alastairs-place.net

Related mailsAuthorDate
mlApp-specific URLs and the pasteboard. Need help. Duncan Champney Jan 18, 16:27
mlRe: App-specific URLs and the pasteboard. Need help. Steve Bird Jan 18, 16:51
mlRe: App-specific URLs and the pasteboard. Need help. Alastair Houghton Jan 18, 17:05
mlRe: App-specific URLs and the pasteboard. Need help. Alastair Houghton Jan 18, 18:21
mlRe: App-specific URLs and the pasteboard. Need help. Alastair Houghton Jan 19, 00:30
mlRe: App-specific URLs and the pasteboard. Need help. Duncan Champney Jan 19, 13:59
mlRe: App-specific URLs and the pasteboard. Need help. Jonathon Mah Jan 20, 10:49
mlRe: App-specific URLs and the pasteboard: Clipboard Viewer tool Duncan Champney Jan 20, 15:29
mlRe: App-specific URLs and the pasteboard. Need help. Duncan Champney Jan 22, 21:44
mlRe: App-specific URLs and the pasteboard. Need help. glenn andreas Jan 22, 23:46
mlRe: App-specific URLs and the pasteboard. Need help. William Bates Jan 23, 13:22