Skip to content

Instantly share code, notes, and snippets.

View Innovatewithapple's full-sized avatar
🎯
Focusing

IWA Innovatewithapple

🎯
Focusing
View GitHub Profile
@Innovatewithapple
Innovatewithapple / AlamofireMethods
Created February 1, 2024 08:15
All Alamofire Methods
//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)")
}
@Innovatewithapple
Innovatewithapple / RealmDB.txt
Created February 1, 2024 07:50
RealmDB Snippt
class DatabaseHelper {
static let shared = DatabaseHelper()
private var realm = try! Realm()
private init(){}
func getDatabaseURL() -> URL? {
return Realm.Configuration.defaultConfiguration.fileURL
}
@Innovatewithapple
Innovatewithapple / IWADecimalFormat
Last active July 26, 2023 07:06
Format Double or Float values without rounded. Use this method and set maximum decimals according to your need.
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
@Innovatewithapple
Innovatewithapple / StatusBarColorChange
Created July 11, 2023 07:16
iOS Status bar color change working with iOS13+. Call this function in viewDidLoad() method
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
@Innovatewithapple
Innovatewithapple / InfoPlist
Created June 27, 2023 08:16
Info.Plist property for top date,time appearance color based on boolean value
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
@Innovatewithapple
Innovatewithapple / UIImage+Extensions
Created June 27, 2023 08:09
UiImage Extension for different image conversions
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)
@Innovatewithapple
Innovatewithapple / UIColor+Extension
Last active June 27, 2023 08:06
UIColor Properties for Hex into RGB
//
// UIColor+Extensions.swift
// AnimationSeries
//
// Created by Mihir vyas on 27/06/23.
//
import Foundation
import UIKit