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
| // outlet to the super view | |
| @IBOutlet weak var gameView: UIView! | |
| // creating your subview via lazy allows you to reach the gameView outlet after intializing, otherwise it wouldn't be there to reach | |
| lazy var ball: UIView = { | |
| let ballview = UIView(frame: CGRect(origin: CGPoint(x: self.gameView.bounds.midX, y: self.gameView.bounds.midY) , size: CGSize(width: 25, height: 25))) | |
| ballview.backgroundColor = UIColor.blueColor() | |
| ballview.layer.cornerRadius = 3 | |
| self.gameView.addSubView(ballview) | |
| return ballview |
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
| // Fast. | |
| Array.removeAtIndex(0) | |
| //same job, a bit slower. | |
| Array(edited.dropFirst()) |
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
| // printing an Int array: | |
| // MARK: - First method | |
| let res = Array.map { String($0) } | |
| print(res.joinWithSeparator(" ")) | |
| //MARK: - Second method | |
| _ = leftShift(x, times: 4).map { print("\($0) ", terminator: "") } |
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
| func loadMoreChatMessages() { | |
| self.showLoadEarlierMessagesHeader = false | |
| page += 1 | |
| let bottomOffset = self.collectionView.contentSize.height - self.collectionView.contentOffset.y | |
| CATransaction.begin() | |
| CATransaction.setDisableActions(true) | |
| fetchChatData(false) {[unowned self] (_) in | |
| if !self.historyMessages.isEmpty { |
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
| // Create CustomView.xib, set File's Owner to CustomView. | |
| // Link the top level view in the XIB to the contentView outlet. | |
| class CustomView : UIView { | |
| @IBOutlet private var contentView:UIView? | |
| // other outlets | |
| override init(frame: CGRect) { // for using CustomView in code | |
| super.init(frame: frame) | |
| self.commonInit() |
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
| // CircleView.swift | |
| // OpenSource | |
| // | |
| // Created by abdelrahman mohamed on 2/13/18. | |
| // Copyright © 2018 abdelrahman mohamed. All rights reserved. | |
| // | |
| import UIKit | |
| @IBDesignable |
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
| // | |
| // GradientView.swift | |
| // | |
| // Created by abdelrahman mohamed on 3/19/18. | |
| // Copyright © 2018 abdelrahman mohamed. All rights reserved. | |
| // | |
| import UIKit | |
| @IBDesignable public class GradientView: UIView { |
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 Alamofire | |
| protocol URLRequestBuilder: URLRequestConvertible { | |
| var mainURL: URL { get } | |
| var requestURL: URL { get } | |
| // MARK: - Path | |
| var path: ServerPaths { get } |
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 UserRequest: URLRequestBuilder { | |
| case login(email: String, password: String) | |
| case register(name: String, email: String, password: String, phone: String) | |
| case userInfo | |
| // MARK: - Path | |
| internal var path: ServerPaths { | |
| switch self { | |
| case .login: |
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 ServerPaths: String { | |
| case login | |
| case register | |
| case phoneActivation = "phone_activation" | |
| case resendPhoneActivation = "resend_phone_activation_code" | |
| case resendEmailLink = "send_reset_link_email" | |
| case resetPassword = "reset_password" | |
| case userInfo = "get_account_info" | |
| case updateInfo = "update_account_info" | |
| case userBalance = "get_user_internal_balance" |