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
//GET | |
func makeGetRequest() { | |
AF.request("https://api.example.com/data") | |
.responseData { response in | |
switch response.result { | |
case .success(let data): | |
print("GET Success: \(data)") | |
case .failure(let error): | |
print("GET Error: \(error)") | |
} |
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
class DatabaseHelper { | |
static let shared = DatabaseHelper() | |
private var realm = try! Realm() | |
private init(){} | |
func getDatabaseURL() -> URL? { | |
return Realm.Configuration.defaultConfiguration.fileURL | |
} |
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 IWADoubleFormat(_ a: Double, max: Int) -> Double { | |
let stringArr = String(a).split(separator: ".") | |
let decimals = Array(stringArr[1]) | |
var string = "\(stringArr[0])." | |
var count = 0; | |
for n in decimals { | |
if count == max { break } | |
string += "\(n)" | |
count += 1 |
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 SetupStatusBar(color:String) { | |
if #available(iOS 13.0, *) { | |
let app = UIApplication.shared | |
let statusBarHeight: CGFloat = app.statusBarFrame.size.height | |
let statusbarView = UIView() | |
statusbarView.backgroundColor = UIColor(hexString: color) | |
view.addSubview(statusbarView) | |
statusbarView.translatesAutoresizingMaskIntoConstraints = false |
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
<key>UIUserInterfaceStyle</key> | |
<string>Light</string> | |
<key>UIViewControllerBasedStatusBarAppearance</key> | |
<false/> |
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 UIImage { | |
/// Convert UIImage into Black & White | |
var noir: UIImage? { | |
let context = CIContext(options: nil) | |
guard let currentFilter = CIFilter(name: "CIPhotoEffectNoir") else { return nil } | |
currentFilter.setValue(CIImage(image: self), forKey: kCIInputImageKey) | |
if let output = currentFilter.outputImage, | |
let cgImage = context.createCGImage(output, from: output.extent) { | |
return UIImage(cgImage: cgImage, scale: scale, orientation: imageOrientation) |
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
// | |
// UIColor+Extensions.swift | |
// AnimationSeries | |
// | |
// Created by Mihir vyas on 27/06/23. | |
// | |
import Foundation | |
import UIKit |