简体   繁体   中英

Getting URL from Mac App

What would I put into an IBAction to get a URL (email, or HTTP) that opens a browser?

Thanks!

Open page in Safari:

NSURL *url = [[NSURL alloc] initWithString: @"http://www.google.com/"];
[[UIApplication sharedApplication] openURL:url]

Create new message within Mail:

NSString *subject = @"The subject";
NSString *body = @"The message";
NSString *address = @"mail@address.com";
NSString *cc = @"mail@address.com";
NSString *path = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@", address, cc, subject, body];
NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM