开发者

Why is UIApplication not working in my Mac App

i am using openURL for my iphone apps, works perfectly, but now i want to use it on mac, normally, i use this code

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://google.com"]];

and it works perfectly in Xcode for iPhone app, but wh开发者_运维问答en doing a mac app, it gets me this error:

"UIApplication" undeclared (first use in this function)

So help anyone?


As others have said, UIApplication is part of UIKit, a Cocoa Touch framework for iOS. On the Mac, you have to use AppKit, a Cocoa framework for Mac OS X, which provides NSApplication.

That being said, if you want to open a URL you need to use NSWorkspace:

[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://google.com"]];


You can't use UIApplication. You need to use NSApplication instead.


try NSApplication

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜