Re: NSURL question (not so easy (i think))
Re: NSURL question (not so easy (i think))
- Subject: Re: NSURL question (not so easy (i think))
- From: Mamdouh <email@hidden>
- Date: Thu, 30 May 2002 21:22:13 +0200
Hi John (and others that answered) ...
Thanks again for your help on the StringWithFormat thing, it worked
great! But now i4m having a problem with mailto: URL4s! It seems like
CFURL or NSURL doesn't support spaces in URL4s, and thats what i4m gonna
use to do what i4m try4eng to do!
I4ll start by explaining what i4m try4ng to do, and then, if you have
time, you could help me:
I working on a document documentbasedbased app that saves an opens text
files; a texteditor... The app consists of a most important thing (right
now) of the app is the main window which has a NSTextView... What i4m
try4ng to do is send the text inside the NSTextView by mail, using the
default email app! I made a window which has 3 NSTextFields inside, an
email-to field, a cc-field and a subject-field...
So i wrote a method that take the value of these 3 fields, and the value
of the NSTextView, and converts it into a mailto URL!
Such a URL can look like this:
mailto:(receiver)?cc=(CC-Receiver)&subject=(subject can have
spaces)&body=(which consists of words and spaces)
example:
mailto:email@hidden?cc=cocoa-
email@hidden&subject=Re:NSURL question&body=word space word space
word space . Word space, space word
Try typing this into IE, and woupti, Mail starts, makes a new message,
and (badabum) it has all the spaces inside the subject and inside the
body!
But CFURL/NSURL from inside my app seems not to have support for spaces
in urls, so if the user of my app writes more then 1 word with one space
i get an error that says that this is not a valid URL! So as you can see
this is huge problem.. Just think about how many subjects/documents that
are written and consists of only one word and one space...
So my question is:
How can i somehow invoke NSURL so it can recive URL4s that have spaces
in them???
Heres a snip of code:
<<<<<<<<<<<<<<<<<<
NSString *ToString= [MailToField stringValue];
NSString *CCString= [MailToField stringValue];
NSString *SubjectString= [MailSubjectField stringValue];
NSString *BodyString= [MDTextView string];
//NSString *BodyString= [MDTextView string:(NSMakeRange(0,
[[MDTextView string] length]))];
MyUrlString = [NSString
stringWithFormat:@"
mailto:%@?cc=%@&subject=%@&body=%@", ToString,
CCString, SubjectString, BodyString];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:
MyUrlString]];
>>>>>>>>>>>>>>>>>>
Thanks in advance
Mamdouh
Student/Programmer
On torsdag, maj 30, 2002, at 12:36 , John Blackburn wrote:
You want to do this:
MyUrlString = [NSString stringWithFormat:@"
http://www.%@.com",
MyUrlString];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:
MyUrlString]];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.