nsurl

Creating URL query parameters from NSDictionary objects in ObjectiveC

徘徊边缘 提交于 2019-11-26 03:44:42
With all the URL-handling objects lying around in the standard Cocoa libraries (NSURL, NSMutableURL, NSMutableURLRequest, etc), I know I must be overlooking an easy way to programmatically compose a GET request. Currently I'm manually appending "?" followed by name value pairs joined by "&", but all of my name and value pairs need to be manually encoded so NSMutableURLRequest doesn't fail entirely when it tries to connect to the URL. This feels like something I should be able to use a pre-baked API for.... is there anything out of the box to append an NSDictionary of query parameters to an

How to use special character in NSURL?

帅比萌擦擦* 提交于 2019-11-26 02:38:34
问题 My application is using an NSURL like this: var url = NSURL(string: \"http://www.geonames.org/search.html?q=Aïn+Béïda+Algeria&country=\") When I tried to make a task for getting data from this NSURL like this: let task = NSURLSession.sharedSession().dataTaskWithURL(url!, completionHandler: { (data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in if error == nil { var urlContent = NSString(data: data, encoding: NSUTF8StringEncoding) println(\"urlContent \\(urlContent!)\") } else

NSURL path vs absoluteString

无人久伴 提交于 2019-11-26 02:30:22
问题 I\'ve seen many questions on SO concerning converting between NSURL and NSString . They all involve using either NSString *path = [myURL absoluteString]; or NSString *path = [myURL path]; . What is the actual difference between these methods? Is there a time when one should be used over the other? I tried consulting the Apple Docs, but I found it less than helpful. I\'m used to URL\'s only being mentioned in discussions concerning websites and other topics regarding sending information

Creating URL query parameters from NSDictionary objects in ObjectiveC

独自空忆成欢 提交于 2019-11-26 01:53:42
问题 With all the URL-handling objects lying around in the standard Cocoa libraries (NSURL, NSMutableURL, NSMutableURLRequest, etc), I know I must be overlooking an easy way to programmatically compose a GET request. Currently I\'m manually appending \"?\" followed by name value pairs joined by \"&\", but all of my name and value pairs need to be manually encoded so NSMutableURLRequest doesn\'t fail entirely when it tries to connect to the URL. This feels like something I should be able to use a

How do I load an HTTP URL with App Transport Security enabled in iOS 9? [duplicate]

安稳与你 提交于 2019-11-25 21:43:53
问题 This question already has an answer here: Transport security has blocked a cleartext HTTP 25 answers So, the new beta SDK of iOS released last night has \"App Transport Security\" which encourages developers to use https instead of http. In principle, this is a great idea, and I already use https in our staging/production environments. However, I don\'t have https set up in my local development environment, when the iOS app is connecting to a web service I\'m running on my laptop. From a bit

Loading/Downloading image from URL on Swift

﹥>﹥吖頭↗ 提交于 2019-11-25 21:41:56
问题 I\'d like to load an image from a URL in my application, so I first tried with Objective-C and it worked, however, with Swift, I\'ve a compilation error: \'imageWithData\' is unavailable: use object construction \'UIImage(data:)\' My function: @IBOutlet var imageView : UIImageView override func viewDidLoad() { super.viewDidLoad() var url:NSURL = NSURL.URLWithString(\"http://myURL/ios8.png\") var data:NSData = NSData.dataWithContentsOfURL(url, options: nil, error: nil) imageView.image =