Skip to content

Instantly share code, notes, and snippets.

View DejanEnspyra's full-sized avatar

Dejan Atanasov DejanEnspyra

View GitHub Profile
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@DejanEnspyra
DejanEnspyra / ViewController.swift
Last active November 2, 2017 11:25
Example of organizing UIViewController class with the help of extensions
//
// ViewController.swift
//
// Created by Dejan Atanasov on 01/04/2017.
// Copyright © 2017 Dejan Atanasov. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@DejanEnspyra
DejanEnspyra / CameraHandler.swift
Last active September 12, 2023 11:00
Access iOS Camera and Photo Library with Swift 3. http://theappspace.com/swift-access-ios-camera-photo-library/
//
// CameraHandler.swift
// theappspace.com
//
// Created by Dejan Atanasov on 26/06/2017.
// Copyright © 2017 Dejan Atanasov. All rights reserved.
//
import Foundation
import UIKit
@DejanEnspyra
DejanEnspyra / multipart.swift
Created July 2, 2017 07:55
Alamofire 4 — Multipart file upload with Swift 3 (http://theappspace.com/multipart-file-upload/)
func requestWith(endUrl: String, imageData: Data?, parameters: [String : Any], onCompletion: ((JSON?) -> Void)? = nil, onError: ((Error?) -> Void)? = nil){
let url = "http://google.com" /* your API url */
let headers: HTTPHeaders = [
/* "Authorization": "your_access_token", in case you need authorization header */
"Content-type": "multipart/form-data"
]
Alamofire.upload(multipartFormData: { (multipartFormData) in
import Foundation
import UIKit
extension UITextField{
@IBInspectable var doneAccessory: Bool{
get{
return self.doneAccessory
}
set (hasDone) {
@DejanEnspyra
DejanEnspyra / IAPHandler.swift
Created July 18, 2017 18:13
[SWIFT] How to add In-App Purchases in your iOS app.
//
// IAPHandler.swift
//
// Created by Dejan Atanasov on 13/07/2017.
// Copyright © 2017 Dejan Atanasov. All rights reserved.
//
import UIKit
import StoreKit
@DejanEnspyra
DejanEnspyra / ReoderGesture.swift
Created August 1, 2017 15:44
Reodering gesture used for controlling drag and drop feature in UICollectionView
fileprivate var longPressGesture: UILongPressGestureRecognizer!
override func viewDidLoad() {
super.viewDidLoad()
longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongGesture(gesture:)))
reorderCollectionView.addGestureRecognizer(longPressGesture)
}
@objc func handleLongGesture(gesture: UILongPressGestureRecognizer) {
@DejanEnspyra
DejanEnspyra / testmodel.swift
Created September 20, 2017 15:48
CleanSwift architecture - Models component
import UIKit
struct TestModel{
struct Fetch {
struct Request
{
var itemId = 0
var keyword: String?
var count: String?
}
@DejanEnspyra
DejanEnspyra / testrouter.swift
Last active September 20, 2017 16:39
CleanSwift architecture - Router component
import UIKit
protocol TestRouterInput {
func showSomeVC()
}
class TestRouter: TestRouterInput
{
weak var viewController: ViewController!
@DejanEnspyra
DejanEnspyra / testworker.swift
Last active September 20, 2017 17:06
Clean Swift architecture - Worker component
typealias responseHandler = (_ response:TestModel.Fetch.Response) ->()
class TestWorker{
func fetch(itemId:Int!, keyword:String!, count: String!, success:@escaping(responseHandler), fail:@escaping(responseHandler))
{
// NOTE: Do the work
//call network etc.
let manager = YourApiManager()