One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
| class Node<T: Equatable> { | |
| var value: T | |
| var next: Node<T>? | |
| init(_ value: T) { | |
| self.value = value | |
| } | |
| } | |
| extension Node { | |
| func map<U>(completion: (T) -> U?) -> Node<U>? { |
| struct Version<ContextType, ValueType> { | |
| let context: ContextType | |
| let value: ValueType | |
| } | |
| class SingleCache<ContextType, ValueType> { | |
| typealias CacheVersion = Version<ContextType, ValueType> | |
| typealias CompletionHandler = (_ oldValue: CacheVersion?, _ newValue: CacheVersion?) -> () |
| var GlobalMainQueue: dispatch_queue_t { | |
| return dispatch_get_main_queue() | |
| } | |
| var GlobalUserInteractiveQueue: dispatch_queue_t { | |
| return dispatch_get_global_queue(Int(QOS_CLASS_USER_INTERACTIVE.value), 0) | |
| } | |
| var GlobalUserInitiatedQueue: dispatch_queue_t { | |
| return dispatch_get_global_queue(Int(QOS_CLASS_USER_INITIATED.value), 0) |
| Nonatomic: | |
| Nonatomic is used for multi threading purposes. If we have set the nonatomic attribute at the time of declaration, then any other thread wanting access to that object can access it and give results in respect to multi-threading. | |
| Copy: | |
| Copy is required when the object is mutable. Use this if you need the value of the object as it is at this moment, and you don't want that value to reflect any changes made by other owners of the object. You will need to release the object when you are finished with it because you are retaining the copy. | |
| Assign: | |
| Assign is somewhat the opposite to copy. When calling the getter of an assign property, it returns a reference to the actual data. Typically you use this attribute when you have a property of primitive type (float, int, BOOL...) | |
| Retain: |
| extension Dictionary { | |
| func valuesForKeys(keys: [Key])->[Value?]{ | |
| var result = [Value?]() | |
| result.reserveCapacity(keys.count) | |
| for key in keys{ | |
| result.append(self[key]) | |
| } | |
| return result | |
| } | |
| } |
| dowloadImage("link", completion: {(var image) in | |
| if image { | |
| // downloaded successfully | |
| } | |
| }) | |
| // dowload image with completion handler | |
| func dowloadImage(link: String, completion:(image: UIImage) -> Void){ | |
| dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { |
| // | |
| // AccordionTableView.swift | |
| // PracticePro | |
| // | |
| // Created by Muzahidul Islam on 5/26/15. | |
| // | |
| import UIKit |
| func + (left: CGPoint, right: CGPoint) -> CGPoint { | |
| return CGPoint(x: left.x + right.x, y: left.y + right.y) | |
| } | |
| func - (left: CGPoint, right: CGPoint) -> CGPoint { | |
| return CGPoint(x: left.x - right.x, y: left.y - right.y) | |
| } | |
| func * (point: CGPoint, scalar: CGFloat) -> CGPoint { | |
| return CGPoint(x: point.x * scalar, y: point.y * scalar) |