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 calculateAverage(total: Int, countOfNumbers: Int) -> Int { | |
return total / countOfNumbers | |
} | |
func average(algorithm: (Int, Int) -> Int, numbers: Int...) -> Int { | |
var countOfNumbers = 0 | |
var total = 0 | |
for number in numbers { | |
total += number |
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
prefix func ++(inout x: Int) -> Int { | |
x = x + 1 | |
return x | |
} | |
postfix func ++(inout x: Int) -> Int { | |
let oldX = x | |
x = x + 1 | |
return oldX | |
} |
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
// | |
// AppConst.swift | |
// AdBlockSample | |
// | |
// Created by bright on 2016/11/26. | |
// Copyright © 2016年 bright. All rights reserved. | |
// | |
import Foundation | |
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
import Foundation | |
import CoreTelephony | |
class OperatorInfo { | |
func id() -> String { | |
let networkInfo = CTTelephonyNetworkInfo() | |
let carrier = networkInfo.subscriberCellularProvider | |
let mcc = carrier!.mobileCountryCode | |
let mnc = carrier!.mobileNetworkCode |
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 currentViewController(_ viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? { | |
guard let viewController = viewController else { return nil } | |
if let viewController = viewController as? UINavigationController { | |
if let viewController = viewController.visibleViewController { | |
return currentViewController(viewController) | |
} else { | |
return currentViewController(viewController.topViewController) | |
} | |
} else if let viewController = viewController as? UITabBarController { |
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
# Find all the available rules by running: | |
# swiftlint rules | |
disabled_rules: # rule identifiers to exclude from running | |
# - colon | |
# - comma | |
- control_statement | |
# - trailing_whitespace | |
opt_in_rules: # some rules are only opt-in | |
- empty_count |
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 Foundation | |
@IBDesignable class PlaceholderTextView: UITextView, UITextViewDelegate | |
{ | |
private let _placeholderColor: UIColor = UIColor(white: 0.78, alpha: 1) | |
private var _placeholderLabel: UILabel! | |
@IBInspectable var placeholder: String = "" { | |
didSet { |
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
// | |
// User.swift | |
// MVVM | |
// | |
// Created by Milan Panchal on 19/03/20. | |
// Copyright © 2020 Jeenal Infotech. All rights reserved. | |
// | |
import UIKit | |
struct UserList: Codable { |
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
// 20200320153014 | |
// https://randomuser.me/api/?results=20 | |
{ | |
"results": [ | |
{ | |
"gender": "male", | |
"name": { | |
"title": "Mr", | |
"first": "Victor", |
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
// | |
// UserViewModel.swift | |
// MVVM | |
// | |
// Created by Milan Panchal on 19/03/20. | |
// Copyright © 2020 Jeenal Infotech. All rights reserved. | |
// | |
import UIKit |
OlderNewer