NSAppleScript *script= [[NSAppleScript alloc] initWithSource:@"tell application \"Safari\" to return URL of front document as string"];NSDictionary *scriptError = nil;NSAppleEventDescriptor *descriptor = [script executeAndReturnError:&scriptError];if(scriptError) { NSLog(@"Error: %@",scriptError);} else { NSAppleEventDescriptor *unicode = [descriptor coercetoDescriptorType:typeUnicodeText]; NSData *data = [unicode data]; Nsstring *result = [[Nsstring alloc] initWithCharacters:(unichar*)[data bytes] length:[data length] / sizeof(unichar)]; NSLog(@"Result: %@",result);}
输出:
Result: https://stackoverflow.com/questions/6111275/how-to-copy-the-current-active-browser-url/6111592#6111592总结
以上是内存溢出为你收集整理的objective-c – 如何复制当前活动的浏览器URL?全部内容,希望文章能够帮你解决objective-c – 如何复制当前活动的浏览器URL?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)