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
@implementation UITextView (Annex) | |
@dynamic visibleTextRange; | |
- (NSRange)visibleTextRange | |
{ | |
CGRect bounds = self.bounds; | |
CGSize textSize = [self.text sizeWithFont:self.font constrainedToSize:bounds.size]; | |
UITextPosition *start = [self characterRangeAtPoint:bounds.origin].start; |
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
var query: PFQuery = PFQuery(className: "userPhoto") | |
query.findObjectsInBackgroundWithBlock { [weak self] (objects, error) -> Void in | |
if let weakSelf = self { | |
println("Got \(objects.count) entries") | |
weakSelf.feedData = objects | |
weakSelf.tableView.reloadData() | |
} | |
} |
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
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { | |
// do some stuff in the background | |
let string = "my string" | |
// remove if you don't need to call the main queue | |
dispatch_async(dispatch_get_main_queue(), { | |
// do some stuff in the main queue | |
// mostly call the UI | |
}) | |
// end of remove |
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
// | |
// SwiftUtilities.swift | |
// | |
// Created by Axel Rivera on 12/21/14. | |
// Copyright (c) 2014 Axel Rivera. All rights reserved. | |
// | |
import Foundation | |
// MARK: - Macros |
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
extension UIColor { | |
convenience init(hex: NSInteger) { | |
self.init(hex: hex, alpha: 1.0) | |
} | |
convenience init (hex: NSInteger, alpha: CGFloat) { | |
let red = CGFloat((hex & 0xFF0000) >> 16) / 255.0 | |
let green = CGFloat((hex & 0xFF00) >> 8) / 255.0 | |
let blue = CGFloat((hex & 0xFF)) / 255.0 |
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 | |
typealias TableInfo = [String: Any] | |
typealias TableSectionArray = [TableSection] | |
typealias TableRowArray = [TableRow] | |
enum TableRowType { | |
case Text | |
case Detail | |
case Subtitle |
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
extension NSURLSession { | |
class func sendSynchronousRequest(request: NSURLRequest, inout returningResponse: NSHTTPURLResponse?, inout error: NSError?) -> NSData? { | |
var data: NSData? | |
var sem: dispatch_semaphore_t | |
sem = dispatch_semaphore_create(0) | |
NSURLSession.sharedSession().dataTaskWithRequest(request) { (requestData, requestResponse, requestError) in |
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
_SECTION_BEGIN("Price"); | |
SetChartOptions(0,chartShowArrows|chartShowDates); | |
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); | |
upColor = ParamColor("Up Color", colorBlack); | |
downColor = ParamColor("Down Color", colorRed); | |
Plot(C, "Close", IIf(C >= Ref(C, -1), upColor, downColor), styleBar); |
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 | |
typealias TableInfo = [String: Any] | |
typealias TableSectionArray = [TableSection] | |
typealias TableRowArray = [TableRow] | |
struct TableSection { | |
var groupIdentifier: String? | |
var identifier: String? | |
var title: String? |
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
// | |
// MKMapView+ShowHide.swift | |
// | |
// Created by Daniel Rotärmel on 27.10.20. | |
// | |
import MapKit | |
// MKAnnotationView extensions to show/hide annotations completely | |
extension MKMapView { |