nsurl

Objective-C / C pulling private key (modulus) from SecKeyRef

我是研究僧i 提交于 2019-12-01 21:55:58
问题 I need a clean way to pull out my servers public key and compare it to local data in order to defend against expiring / renewed keys in the future, but I can't seem to get at the 256 bit key or express it as useful data for comparison... Here's what I have so far... -(BOOL)trustCertFromChallenge:(NSURLAuthenticationChallenge *)challenge { SecTrustResultType trustResult; SecTrustRef trust = challenge.protectionSpace.serverTrust; OSStatus status = SecTrustEvaluate(trust, &trustResult); NSString

Issue with encoding “&” in URLs

跟風遠走 提交于 2019-12-01 21:01:11
I've got to send a https GET request to a web service in my iPhone app which is developing in Swift 1.2. I am trying to construct query string parameters but got to encode them before send to server. All good but not working when password contains '&' charcter. Expect to encode '&' character to '%26' but NOT working... Just done a test when having '%'. Works as expected with '%' providing '%25'. But NOT convert '&' sign.... Tried following ways: var testPassword1: String = "mypassword&1" var testPassword2: String = "mypassword%1" // Try to encode 'testPassword1' testPassword1

UIWebView: Error while loading URL

我与影子孤独终老i 提交于 2019-12-01 18:19:18
I am trying to build an RSS reader for the Tom's Hardware website. I have an error when I try to load an URL into an UIWebview from an RSS link. Here'is my code: - (void)viewDidLoad { [super viewDidLoad]; if (self.url != nil) { NSURL *requestUrl = [NSURL URLWithString:self.url]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:requestUrl]; [webView loadRequest:requestObj]; } } The url is setted by the parent controller. When the URL comes directly from the RSS, I have an error in log: [2234:207] Error Domain=WebKitErrorDomain Code=101 UserInfo=0x3a6a240 "Operation could not be completed

NSURLErrorDomain with code=-1100

ぐ巨炮叔叔 提交于 2019-12-01 17:22:59
I was trying to download a picture to my app from The request failed with the error NSURLErrorDomain and the code is really -1100. The url should be correct since I checked it in the browser. Anyone knows why? let userImageURL: String! = "http://i.imgur.com/QhCzQoR.jpg"; let url = NSURL(fileURLWithPath: userImageURL); let request:NSURLRequest = NSURLRequest(URL: url!) NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: { (response:NSURLResponse!, imageData:NSData!, error:NSError!) -> Void in let image = UIImage(data: imageData!); }) The

Encode '+' using URLComponents in Swift

我们两清 提交于 2019-12-01 16:03:05
This is how I add a query params to a base URL: let baseURL: URL = ... let queryParams: [AnyHashable: Any] = ... var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: false) components?.queryItems = queryParams.map { URLQueryItem(name: $0, value: "\($1)") } let finalURL = components?.url The problem emerges when one of values contains a + symbol. For some reason it's not encoded to %2B in the final URL, instead it stays + . If I do encoding myself and pass %2B , NSURL encodes % and the 'plus' becomes %252B . The question is how can I have %2B in the instance of NSURL ? P.S. I

Why does using Nsurl request keeps telling me to rename to “init(url)”

混江龙づ霸主 提交于 2019-12-01 14:20:17
Also trying to add the ability to detect a video and download it to the application in short a web-based app used for download any kind of video and has the ability to store it within the app import UIKit class ViewController: UIViewController { @IBOutlet var Webview: UIWebView! @IBOutlet var SearchBar: UISearchBar! override func viewDidLoad() { let url = NSURL(string: "https://www.google.com") let request = NSURLRequest(URL: url! as URL) Webview.loadRequest(request) SearchBar.text = "http://" } func searchBarSearchButtonClicked(searchbar: UISearchBar) { searchbar.resignFirstResponder() let

Encode '+' using URLComponents in Swift

半腔热情 提交于 2019-12-01 14:16:45
问题 This is how I add a query params to a base URL: let baseURL: URL = ... let queryParams: [AnyHashable: Any] = ... var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: false) components?.queryItems = queryParams.map { URLQueryItem(name: $0, value: "\($1)") } let finalURL = components?.url The problem emerges when one of values contains a + symbol. For some reason it's not encoded to %2B in the final URL, instead it stays + . If I do encoding myself and pass %2B , NSURL encodes

Why does using Nsurl request keeps telling me to rename to “init(url)”

落花浮王杯 提交于 2019-12-01 12:54:52
问题 Also trying to add the ability to detect a video and download it to the application in short a web-based app used for download any kind of video and has the ability to store it within the app import UIKit class ViewController: UIViewController { @IBOutlet var Webview: UIWebView! @IBOutlet var SearchBar: UISearchBar! override func viewDidLoad() { let url = NSURL(string: "https://www.google.com") let request = NSURLRequest(URL: url! as URL) Webview.loadRequest(request) SearchBar.text = "http://

How to get hash fragment of URL from UIWebView

心不动则不痛 提交于 2019-12-01 09:38:38
问题 I'm trying to get hash fragment of URL loaded in UIWebView, I have tried different approaches it does not seem to work. For example if the UIWebView is loaded with "http://www.mysite.com/home#main": NSURL *url = [NSURL URLWithString:@"http://www.mysite.com/home#main"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; then I want to get the full url, but it only return "http://www.mysite.com/home" with 3 different approaches: 1: NSString *currentURL =

Obtain NSURL from UIImagePickerController

喜欢而已 提交于 2019-12-01 09:36:49
I'm attempting to grab the file path of an image selected through an imagePickerController in order to upload the file to Firebase Storage. func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { mediaUploadView.image = info[UIImagePickerControllerOriginalImage] as? UIImage let localUrl: NSURL = (info[UIImagePickerControllerReferenceURL] as! NSURL) print(localUrl) let localFile: NSURL = localUrl let mediaRef = storageRef.child("media") let uploadTask = mediaRef.putFile(localUrl, metadata: nil) { metadata, error in if (error != nil