Tag: url

URLscheme“prefs:root = PASS”iOS10

我知道有很多关于这个问题的话题,但有没有解决scheme? 我还没有find官方的文件。 我的问题是我需要redirect我的代码在这样的存储设置:(工作在iOS 9) let settingsUrl = NSURL(string: "prefs:root=CASTLE&path=STORAGE_AND_BACKUP") if let url = settingsUrl { UIApplication.shared.openURL(url as URL) } 但是既然ios10这个方法不行,那么有没有其他办法呢? 我看到SnapChat,谷歌地图redirect他们的应用程序不同部分的设置(不是设置的主屏幕),所以我认为有一个解决scheme。 我已经在info.plist中实现了urlscheme,但它仍然不起作用 我尝试了这个方法,但同样的问题 let settingsUrl = NSURL(string: "prefs:root=CASTLE&path=STORAGE_AND_BACKUP") if let url = settingsUrl { if #available(iOS 10.0, *) { UIApplication.shared.open(URL.init(string:"Prefs:root=General&path=STORAGE_ICLOUD_USAGE/DEVICE_STORAGE")!, options: [UIApplicationOpenURLOptionUniversalLinksOnly:true], completionHandler:{(success: Bool?) -> Void in}) } else { UIApplication.shared.openURL(url as URL) } } […]

在URL中传递用户名和密码进行身份validation

我想在URL(Web服务)中传递用户名和密码进行用户authentication,这将返回true和false.I'm这样做如下: NSString *userName = [NSString stringWithFormat:@"parameterUser=%@",txtUserName]; NSString *passWord = [NSString stringWithFormat:@"parameterPass=%@",txtPassword]; NSData *getUserData = [userName dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *getUserLength = [NSString stringWithFormat:@"%d",[getUserData length]]; NSData *getPassData = [passWord dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *getPassLength = [NSString stringWithFormat:@"%d",[getPassData length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init]; [request setURL:[NSURL URLWithString:@"http://URL/service1.asmx"]]; [request setHTTPMethod:@"GET"]; 现在,我想知道如何在此URL中传递我的用户名和密码以提出请求。 任何人都可以请build议或给一些示例代码? 谢谢。

如何传递属性swift 3 urlsession didFinishDownloadingTo后台下载后委托?

我可以使用ios 10和swift 3成功下载后台的zip文件。 我使用一个backgroundsession数据任务: let backgroundSessionConfiguration = URLSessionConfiguration.background(withIdentifier: (prefix + postfix)) let backgroundSession = Foundation.URLSession(configuration: backgroundSessionConfiguration, delegate: self, delegateQueue: OperationQueue.main) var request = URLRequest(url: dlUrl ) request.httpMethod = "GET" request.cachePolicy = NSMutableURLRequest.CachePolicy.reloadIgnoringCacheData let task = backgroundSession.downloadTask(with: request) task.resume() 但是我想知道下载完成后,将一些特定的元数据传递给委托方法的最佳做法是什么: func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL){ 我需要在这个委托内有一些关于下载的信息,这取决于用户之前做出的select。 我无法从服务器或url获取这些数据。 所以我想有一个variables或字典downloadType告诉我如何处理完成的下载,在代表有这样的事情 if downloadType == "normal" […]

无法在URL + swift中对Plus字符进行编码

我正在使用GET方法,我必须在URL中传递电子邮件地址。 API期望它被编码。 我尝试了编码选项,但'+'字符不能被编码。 我试着用下面的代码 let encodedEmail = emailAddressTxt.text!.addingPercentEncoding(withAllowedCharacters:.urlHostAllowed) let urlString = "http://www.example.com/User/GetUserDetailsByEmailAddress?EmailAddress=\(encodedEmail!)" print(escapedString) 它打印http://www.example.com/User/GetUserDetailsByEmailAddress?EmailAddress=mano+1%40gmail.com “@”字符只编码,“+”不编码。

如何使用以下方法发布图片数组

我正在使用Swift 3,并想用这种方法张贴图片数组 – 请帮助我该怎么做 if let imageData = UIImageJPEGRepresentation(customKindImage.image! , 1) { print("There is Not Any Images to upload!") let uploadScriptUrl = URL(string : "http://www.swiftdeveloperblog.com/http-post-example-script/") var request = URLRequest(url: uploadScriptUrl!) request.httpMethod = "POST" request.setValue("Keep-Alive" , forHTTPHeaderField : "Connection") let task = URLSession.shared.uploadTask(with: request, from: imageData, completionHandler: { (data, response, error) in guard let _ = […]

URL编码问题在Swift ios中

我从我的服务器响应获取url为: HTTPS://baseURL/The+Man+in+the+High+Castle+Official+Trailer+%E2%80%93+2+th.m3u8 我正在做的编码为: videoURL = videoURL.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())! 但avplayer无法播放这个特定的url。 看起来像编码URL中的一些问题

如何在iOS中播放MP3来自URL

这个问题似乎与许多问题重复。 我已经在这些问题上已经回答了很多答案,但是他们并没有为我工作。 所以我决定再次问这个问题,如果你帮我。 我有一个从webview获得的URL [[[webview request] URL] absoluteString]; 这里是我的代码来播放来自URL的MP3文件: // properties @property (strong,nonatomic) AVPlayerItem *playerItem; @property (strong,nonatomic) AVPlayer *player; // coding NSString *decoded = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (CFStringRef)aSongURL, CFSTR(""), kCFStringEncodingUTF8); NSURL *aURL = [NSURL URLWithString:decoded]; self.playerItem = [AVPlayerItem playerItemWithURL:aURL]; self.player = [AVPlayer playerWithPlayerItem:self.playerItem]; self.player = [AVPlayer playerWithURL:aURL]; [self.player play]; 请帮帮我 编辑 //output aURL = "http://laguboard.com/music/down/33867378/2794942/NTU0NktpZE56eERWZGxVeC9zTS9LVUd1TEhkZTE0cFZuaW1QS1pFMHVhOUNkM2ZoZEE=/(http://mp3xload.wapka.me).mp3"

iOS URLscheme – 在我的应用程序中加载自定义的UIView

我提到这个IOSurl计划启动自定义UIView内我的应用程序 ,但我不清楚他试图回答。 是否有可能通过URLscheme加载自定义的UIVIew通过我的应用程序login屏幕? 我的情景 – 我将自定义视图显示为login视图过程中的popup窗口,在此处检查应用程序是否已接受条款和条件。 它在应用程序在后台运行以及应用程序从已安装的应用程序启动时工作正常。 但是当我从URL Scheme部分启动应用程序时,它运行良好,当应用程序在后台运行,但是当应用程序终止,我打开从应用程序的URL架构,启动应用程序,但自定义视图得到立即隐藏。 – (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; self.isCalledFromSafariBrowser = true; AppCodeViewController_iPad *appCodeViewController = [[AppCodeViewController_iPad alloc]init]; if (!url) { return NO; } NSString *URLString = [url absoluteString]; NSArray *arr = [URLString componentsSeparatedByString:@"?"]; arr = [[arr objectAtIndex:1] […]

iOS:NSString丢失URL,(空)显示

这是我的代码到目前为止: NSString *listedImageURL = listedProduct.image; NSLog(@"URL: %@", listedImageURL); 此代码工作正常,NSLog显示我正确的URL。 但是当我尝试下面的代码,NSLog显示(空): NSString *listedImageURL = listedProduct.image; NSURL *imageURL = [NSURL URLWithString:listedImageURL]; NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; UIImage *image = [UIImage imageWithData:imageData]; 我究竟做错了什么??

RestKit GET请求queryParameter:没有匹配responseDescriptor

我试图用Restkit做一个请求,但我得到以下错误: {Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "No mappable object representations were found at the key paths searched." UserInfo={NSLocalizedDescription=No mappable object representations were found at the key paths searched., NSLocalizedFailureReason=The mapping operation was unable to find any nested object representations at the key paths searched: This likely indicates that you have misconfigured the key paths for your mappings., […]