Tag: url

在UIWebView中使用自定义URLscheme

我有一个黑盒子容器。 我喜欢黑盒子,他们混淆了事情。 这个黑盒子是一个encryption的zip(有点),里面有一些html文件(这是简短的,没有那么痛苦的解释,版本)。 这些文件需要在UIWebView中显示。 现在,简单的方法来解密,解压缩到文件系统,从文件系统加载文件。 这很好,除了黑盒子包含秘密的东西,不能只是躺在文件系统上,甚至不是一秒钟,所以,我做了一个C库,实际上stream的箱子的内容(直接开箱) 。 现在,我有这个stream媒体function,必须以某种方式使其与UIWebView工作。 首先想到的是使用UIWebView可以发送请求的迷你本地HTTP服务器。 然后,我会自己pipe理这些请求,并使用我已经完成的stream式lib返回UIWebView所需的内容。 这可以工作,我想很好,但我认为一个小型的HTTP服务器可能会有点矫枉过正。 所以,我想知道,是否有另一种方式干扰UIWebView和文件系统? 也许使用自定义模式? 像myschema://? 每次UIWebView向myschema://myfile.html发出请求,我都会以某种方式干扰并返回所需的数据? 这样的想法是否可行? 我应该从哪里开始? 也许NSURLRequest? 编辑:我发现这个: iPhone SDK:从自定义URLscheme加载资源 。 但是,听起来不错,浏览器如何知道请求的大小,types(xml / binary / xhtml)以及HTTP头中放置的所有信息?

如何在iOS Swift中获取应用程序的CFBundleURLSchemes

我做了一个演示项目App1,我添加了一个button,将我redirect到已安装的应用程序假设App2(“ fitbit ”)我已经经历了许多教程,基本上得到了这个想法如何通过第二个答案“这个应用程序不允许查询schemecydia“IOS9错误 ,但是在我需要提到App1的LSApplicationQueriesSchemes中的App2的URLscheme(” fitbit “)的地方被卡住了。 所以基本上问题是如何获得像fitbit这样的应用程序的URL Schemes。 这是我的代码 var url = NSURL(string: "itms://itunes.apple.com/in/app/fitbit/id462638897?mt=8") @IBAction func redirectOnclick(_ sender: Any) { let urlFitBt = NSURL(string: "fitbit://") if UIApplication.shared.canOpenURL(urlFitBt! as URL) { UIApplication.shared.open(urlFitBt! as URL) } else { UIApplication.shared.open(url! as URL) } }

操作无法完成。 (cocoa错误-1。) – PHPhotoLibrary

嗨,我想保存一个下载的MP4文件到我的画廊。 使用downloadTaskurl 在 func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL){ } 我得到的url file:///private/var/mobile/Containers/Data/Application/8D761DFE-C050-426D-B91C-61DE441FB496/Library/Caches/com.apple.nsurlsessiond/Downloads/com.te.dn/CFNetworkDownload_KFSYSW.tmp 我正在创build一个path, let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true) let documentDirectoryPath:String = path[0] let fileManager = FileManager() let destinationURLForFile = URL(fileURLWithPath: documentDirectoryPath.appendingFormat("/file1.mp4")) if fileManager.fileExists(atPath: destinationURLForFile.path){ } else{ do { try fileManager.moveItem(at: location, to: destinationURLForFile) // show file }catch{ print("An error occurred while […]

ios prefs urlpathscheme邮件

我似乎无法findpathSeetings->邮件,联系人,日历url计划path的任何地方。 我试过了: @"prefs:root=Mail,Contacts,Calendars"但它只是打开设置,并将表格居中邮件,联系人,日历。 任何想法如何进入? 谢谢

Spotify:使用网页apilogin不接受redirecturl

我正在尝试使用Web APIlogin到Spotify,因为我不需要会话对象。 在我的授权方法中,我需要传入redirecturl,但格式化iOSredirecturl的方式在.GET请求中不被接受。 func authorize() { // create the url let url = "https://accounts.spotify.com/authorize" // parameters let parameters = ["client_id" : kClientID, "response_type" : "code", "redirect_uri" : "spotify-discover-login://callback", "state" : kState, "scope" : kScopes] // response code var responseCode = 401 Alamofire.request(.GET, url, parameters: parameters, headers: nil) .responseString{response in print(response) switch response.result { case .Success: […]

NSFileManager的URL与path

为什么像moveItemAtURL:toURL:error:这样的path方法推荐使用像moveItemAtURL:toURL:error: of NSFileManager类的URL方法moveItemAtPath:toPath:error:

如何在Objective-C中使用URL Xcode 8.1在我的PHP服务器中发送数据

我想从Xcode发送NSString数据到我的PHP服务器,在这个例子中使用url: http : //11.1.12.173 : 1000 我需要XCODE 8.1的解决scheme,因为有些代码在最新的Xcode中不起作用。 NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://11.1.12.173:1000"]]; [req setHTTPMethod:@"POST"]; NSData *postData = [deviceToken dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]]; [req addValue:postLength forHTTPHeaderField:@"Content-Length"]; [req setHTTPBody:postData]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithRequest:req completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { // Do something […]

从url加载.plist文件

我有下面的代码从资源文件夹加载一个plist文件,并使用它来填充tableview: NSString *path = [[NSBundle mainBundle] pathForResource:@"AnimeDB" ofType:@"plist"]; NSMutableArray* tmpArray = [[NSMutableArray alloc] initWithContentsOfFile:path]; self.dataList1 = tmpArray; [tmpArray release]; 但我需要从一个URL加载.plist文件。 我尝试了一些我在网上find的解决scheme,但我无法实现它的工作。 有人知道我该怎么做? 也许有一个简单的解决scheme,但我在Xcode的开始(这是我的第一个应用程序),所以我找不到它。 任何帮助真的很感激! PS对不起,我可能犯了任何错误,我的英语不是那么好。

在Google地图中使用目标c ios打开获取方向

我正在使用谷歌地图sdk,现在我想打开得到的方向,在谷歌地图有多个站像我在地点A,并从那我想去的地点B,C,D我可以打开谷歌地图与地点A到B,但无法打开A到B,C,D 。 我怎么能做到这一点,我试过这个 NSString *str1 =[NSString stringWithFormat:@"http://maps.google.com/?saddr=%@&daddr=%@&waypoints=%@&key=%@",originString,destinationString,strWayPoints,GOOGLE_API_KEY]; if([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://"]]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str1]]; } //str1 = http://maps.google.com/?saddr=18.518205,73.857431&daddr=18.518205,73.857431&waypoints=via:18.518205,73.857431|via:18.552248,73.901596|via:18.629764,73.934685&key=MYKEY

按URL的前缀不同的动作

这是我的情况:我在我的ios应用程序(在Swift中运行)本地调用文件。 如果文件是JPG文件,则会发生一个动作,如果该文件是mp4,则会发生另一个动作。 对于这个我使用这个代码: let urlString = "\(posts[selectedIndexPath].link)" let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let fileName = urlString as NSString; let filePath="\(documentsPath)/\(fileName.lastPathComponent)"; let fileURL = NSURL.init(fileURLWithPath: filePath) let request = NSURLRequest.init(url: fileURL as URL) /* END DOWNLOAD + READ LOCALY */ if (fileURL.pathExtension?.hasPrefix("jpg"))! { Swift.print("THIS IS A JPG") } else if (fileURL.pathExtension == "mp4") { Swift.print("THIS […]