This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.minhwang.myapplication; | |
import android.content.Context; | |
import android.support.test.InstrumentationRegistry; | |
import android.support.test.runner.AndroidJUnit4; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import static org.junit.Assert.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
func pickNumbersRandomly(from numbers: [UInt], theNumberOf: UInt) -> [UInt] { | |
var numbers = numbers | |
var numbersPickedRandomly = [UInt]() | |
for _ in 1...theNumberOf { | |
let indexPickedRandomly = Int(arc4random_uniform(UInt32(numbers.count))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func requestGET(stringURL url:String) -> URLSessionDataTask? { | |
var task: URLSessionDataTask? = nil | |
guard let url: URL = URL(string: url) else { | |
print("URL is invalid..!!") | |
return task | |
} | |
let urlSession = URLSession(configuration: URLSessionConfiguration.default) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func requestGETUsingString(stringURL url:String) { | |
guard let url: URL = URL(string: url) else { | |
print("URL is invalid..!!") | |
return | |
} | |
guard let result = try? String(contentsOf: url) else { | |
print("Error occurred while getting data..!!") | |
return | |
} |