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
extension Data { | |
func printData(with title: String?) { | |
if let title = title { | |
print(title) | |
} | |
if let json = try? JSONSerialization.jsonObject(with: self, options: .mutableContainers), | |
let jsonData = try? JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) { | |
print(String(decoding: jsonData, as: UTF8.self)) | |
} else { | |
String(decoding: self, as: UTF8.self) |
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
```swift | |
import Foundation | |
class PhoneNumberManager { | |
static func readJson() -> [String: Any]? { | |
if let fileUrl = Bundle.main.url(forResource: "DailerCodeTree", withExtension: "json") { | |
do { | |
let data = try Data(contentsOf: fileUrl) | |
let json = try JSONSerialization.jsonObject(with: data, options: []) | |
let dictionary = json as! [String: Any] |
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
import Foundation | |
import HealthKit | |
import RxSwift | |
class HealthKitManager { | |
private let healthStore = HKHealthStore() | |
func requestPermission() -> Observable<Bool> { | |
return .create { [weak self] (observer) -> Disposable in |
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
extension String { | |
func toArray() throws -> [Any] { | |
guard let stringData = data(using: .utf16, allowLossyConversion: false) else { return [] } | |
guard let array = try JSONSerialization.jsonObject(with: stringData, options: .mutableContainers) as? [Any] else { | |
throw JSONError.notArray | |
} | |
return array | |
} | |
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
import UIKit | |
class EmptyDataSet: UIView { | |
private(set) var parentView: UIView! | |
private(set) var titleLabel: UILabel! | |
private(set) var descriptionLabel: UILabel! | |
private(set) var imageView: UIImageView! | |
private(set) var button: UIButton! |
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
import UIKit | |
import UserNotifications | |
class LocalNotificationManager { | |
var notifications = [Notification]() | |
func scheduledNotifications(completion: ([Notification])->()) { | |
if #available(iOS 10.0, *) { | |
UNUserNotificationCenter.current().getPendingNotificationRequests { notifications in |
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
/// View to give shimmering effects. | |
class ShimmerView: UIView { | |
/// Start the shimmering animation. | |
func start() { | |
let light = UIColor.white.cgColor | |
let alpha = UIColor(red: 206/255, green: 10/255, blue: 10/255, alpha: 0.7).cgColor | |
let gradient = CAGradientLayer() | |
gradient.frame = CGRect(x: -self.bounds.size.width, y: 0, width: 3 * self.bounds.size.width, height: self.bounds.size.height) | |
gradient.colors = [light, alpha, light] |
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
import Contacts | |
class PhoneContacts { | |
struct Contact { | |
let givenName: String | |
let middleName: String | |
let familyName: String | |
let phoneNumber: [String] | |
let email: [String] |
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
// | |
// LineChart.swift | |
// LineChart | |
// | |
// Created by Nguyen Vu Nhat Minh on 25/8/17. | |
// Copyright © 2017 Nguyen Vu Nhat Minh. All rights reserved. | |
// | |
// Modified by Anirudha Mahale on 14/11/19. | |
import UIKit |
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
// | |
// PickerView.swift | |
// SlideUpAnimation | |
// | |
// Created by Anirudha Mahale on 17/10/19. | |
// Copyright © 2019 Anirudha Mahale. All rights reserved. | |
// | |
import UIKit | |
import RxSwift |
NewerOlder