Skip to content

Instantly share code, notes, and snippets.

View ahikmatf's full-sized avatar
💭
Learning how to code

Asep Hikmat Fatahillah ahikmatf

💭
Learning how to code
View GitHub Profile
// http://stackoverflow.com/a/28800828/5552518
import Foundation
import Alamofire
class ParallelServiceCaller {
var firstServiceCallComplete = false
var secondServiceCallComplete = false
func startServiceCalls() {
// http://stackoverflow.com/a/33455882/5552518
// xCode 8, Swift 3
import UIKit
@IBDesignable
class SpinnerView: UIView {
override var layer: CAShapeLayer {
get {
// http://stackoverflow.com/q/32371792/5552518
func authenticateUser(completionHandler: (responseObject: String?, error: NSError?) -> ()) {
makeAuthenticateUserCall(completionHandler)
}
func makeAuthenticateUserCall(completionHandler: (responseObject: String?, error: NSError?) -> ()) {
Alamofire.request(.GET, loginUrlString)
.authenticate(user: "a", password: "b")
.responseString { request, response, responseString, responseError in
//http://stackoverflow.com/a/34455483/5552518
git rm $(git ls-files --deleted)
// http://ashishkakkad.com/2016/03/how-to-create-a-wrapper-for-alamofire-and-swiftyjson-swift-ios/
//
// AFWrapper.swift
// AFSwiftDemo
//
// Created by Ashish on 10/4/16.
// Copyright © 2016 Ashish Kakkad. All rights reserved.
//
for view in self.view.subviews{
print(view)
if view.isKind(of: SpinnerView.self) {
view.removeFromSuperview()
}
}
=====
//
// SwiftLoading.swift
// SwiftLoading
//
// Created by Tran Doan San on 10/17/15.
// Copyright © 2015 Tran Doan San. All rights reserved.
//
import UIKit
let transition = CATransition()
transition.duration = 0.5
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromTop
view.window!.layer.add(transition, forKey: kCATransition)
// detect device orientation
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if UIDevice.current.orientation.isLandscape {
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "back-landscape")!)
} else {
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "back-potrait")!)
}
}
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 21))
label.center = CGPoint(x: 160, y: 285)
label.textAlignment = .center
label.text = "I'am a test label"
self.view.addSubview(label)