This file contains hidden or 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
| // | |
| // CountryModel.swift | |
| // Country_List | |
| // | |
| // Created by vishwas ng on 17/07/24. | |
| // | |
| import Foundation | |
| import SwiftData | |
| import UIKit |
This file contains hidden or 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 Combine | |
| enum APIError: Error, LocalizedError { | |
| case unknown, apiError(reason: String) | |
| var errorDescription: String? { | |
| switch self { | |
| case .unknown: | |
| return "Unknown error" |
This file contains hidden or 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
| static func isValidUer(reasonString:String , Success: @escaping AuthSuccessBlock = { _ in }) | |
| { | |
| var policy: LAPolicy? | |
| let context = LAContext() | |
| if #available(iOS 9.0, *) | |
| { | |
| /* | |
| deviceOwnerAuthenticationWithBiometrics can be used when you want to authenticate user solely based on | |
| bioMetric without reverting to PassCode if bioMetric fail |
This file contains hidden or 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
| enum BioMetricSupported:String | |
| { | |
| case touchId = "Touch ID" | |
| case faceId = "Face ID" | |
| case none = "none" | |
| } | |
| @available(iOS 11.0, *) | |
| private func supportedBiometricType () -> BioMetricSupported | |
| { |
This file contains hidden or 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
| static func isDeviceSupportedforAuth () -> Bool | |
| { | |
| let context = LAContext() | |
| var policy: LAPolicy? | |
| policy = .deviceOwnerAuthentication | |
| var err: NSError? | |
| guard context.canEvaluatePolicy(policy!, error: &err) else | |
| { | |
| return false | |
| } |
This file contains hidden or 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
| let reArrangedPersonByAge = personArray.arrangePersonsByAge() | |
| reArrangedPersonByAge.map{print("Person-Rearranged-Age :- \($0.age)")} | |
| let reArrangedPersonBySalary = personArray.arrangePersonsBySalary() | |
| reArrangedPersonBySalary.map{ print("Person-Rearranged-Salary :- \($0.salary)") } |
This file contains hidden or 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 Array where Element == Person | |
| { | |
| func arrangePersonsByAge() -> [Element] | |
| { | |
| var arr = self | |
| arr.sort { (a, b) -> Bool in | |
| a.age > b.age | |
| } | |
| return arr |
This file contains hidden or 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
| let person1 = Person(name:"Jhon" , age:40, salary: 932) | |
| let person2 = Person(name:"david" , age:45, salary: 1876) | |
| let person3 = Person(name:"jim" , age:30, salary: 1763) | |
| let person4 = Person(name:"tom" , age:28, salary: 1527) | |
| let person5 = Person(name:"Harry" , age:50, salary: 13344) | |
| var personArray:[Person] = [person1,person2,person3,person4,person5] | |
| personArray.map{print("Person-Age :- \($0.age)")} |
This file contains hidden or 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
| struct Person | |
| { | |
| var name:String | |
| var age:Int | |
| var salary:Double | |
| } |
This file contains hidden or 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 Array where Element == String | |
| { | |
| func totalCharacterCount() -> Int | |
| { | |
| return reduce(0, { $0 + $1.count}) | |
| } | |
| func wordCount() -> Int | |
| { | |
| return reduce(0, {$0 + $1.components(separatedBy: " ").count}) |
NewerOlder