Re: App-specific URLs and the pasteboard. Need help.
Re: App-specific URLs and the pasteboard. Need help.
- Subject: Re: App-specific URLs and the pasteboard. Need help.
- From: Alastair Houghton <email@hidden>
- Date: Fri, 18 Jan 2008 23:30:33 +0000
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden