이미지 자동 스크롤 라이브러리, JSON stringify 함수
2018. 1. 30. 23:55ㆍ아이폰 개발
Auk, an image slideshow for iOS / Swift
https://github.com/evgenyneu/Auk
// Show remote images scrollView.auk.show(url: "https://bit.ly/auk_image") scrollView.auk.show(url: "https://bit.ly/moa_image") // Show local image if let image = UIImage(named: "bird.jpg") { scrollView.auk.show(image: image) }
// Scroll images automatically with the interval of 3 seconds scrollView.auk.startAutoScroll(delaySeconds: 3)
Array or Dictionary Object to JSON String
func JSONStringify(value: AnyObject, prettyPrinted: Bool = false) -> String {
let options = prettyPrinted ? JSONSerialization.WritingOptions.prettyPrinted : []
if JSONSerialization.isValidJSONObject(value) {
do {
let data = try JSONSerialization.data(withJSONObject:value, options:options)
if let jsonString = String(data: data, encoding: String.Encoding.utf8) {
return jsonString
}
} catch {
print("JSON serialization failed: \(error)")
}
}
return ""
}