Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun main(args: Array<String>) {
- autoreleasepool {
- runApp("https://feeds.feedburner.com/kotlin")
- }
- }
- private fun runApp(url: String) {
- println("runApp called")
- val session = NSURLSession.sessionWithConfiguration(
- NSURLSessionConfiguration.defaultSessionConfiguration(),
- object : NSObject(), NSURLSessionDataDelegateProtocol {
- override fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition) -> Unit) {
- println("didReceiveResponse called")
- completionHandler(NSURLSessionResponseAllow)
- }
- override fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData: NSData) {
- println("didReceiveData called")
- }
- override fun URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError: NSError?) {
- println("didCompleteWithError called")
- }
- },
- delegateQueue = NSOperationQueue.mainQueue()
- )
- session.dataTaskWithURL(NSURL(URLString = url)).resume()
- }
Advertisement
Add Comment
Please, Sign In to add comment