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
@protocol MyImageDownloaderDelegate <NSObject> | |
- (void)downloadFailed; | |
- (void)imageDownloadFinished:(UIImage *)image; | |
- (void)progressUpdated:(CGFloat)progress; | |
@end | |
@interface MyImageDownloader : NSObject |
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
//Create the rect you would like your text to be inside of... | |
CGRect maxTextRect = CGRectMake(0, 0, 200, 60); | |
//Create the attributed string | |
NSAttributedString *theString = //... do all the setup. | |
//Find the rect that the string will draw into **inside the maxTextRect** | |
CGRect actualRect = [theString boundingRectWithSize:maxTextRect.size options:NSStringDrawingUsesLineFragmentOrigin context:nil]; | |
//Offset the actual rect inside the maxTextRect |
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
== Search for a book by its cover | |
Playing on the saying "Don't judge a book by its cover" I created this so that if you see a book online or in a shop but you forget what it's called you can find it by recalling details about the cover. | |
//hide | |
//setup | |
[source, cypher] | |
---- | |
//publishers |
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 "UserSearchViewController.h" | |
@interface UserSearchViewController () <UISearchBarDelegate, UISearchDisplayDelegate> | |
@end | |
@implementation UserSearchViewController | |
- (void)viewDidLoad | |
{ |
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 | |
// binary search function to find position | |
func findPositionInArray<T: Comparable>(array: [T], value: T) -> Int { | |
var lowerIndex = 0 | |
var upperIndex = array.count - 1 | |
while lowerIndex < upperIndex { | |
let currentIndex = lowerIndex + Int(Double(upperIndex - lowerIndex) * 0.5) | |
let currentValue = array[currentIndex] |
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
// Challenge set here... | |
// https://blog.svpino.com/2015/06/07/programming-challenge-towers-of-hanoi | |
import UIKit | |
// convenience for printing | |
func moveRing(ring : Int, currentPole: Int, targetPole: Int) { | |
println("Move ring \(ring) from pole \(currentPole) to pole \(targetPole)") | |
} |
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
enum Router: URLRequestConvertible { | |
static let baseURLString = "http://someURL.co.uk" | |
static var OAuthToken: String? { | |
didSet { | |
// save token to keychain | |
} | |
} | |
case AuthCheck |
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 | |
import GameplayKit | |
enum ValidationResult<T: Error> { | |
case valid | |
case invalid(error: T) | |
} | |
class Fact<T: Error>: NSObject { | |
let error: T |
OlderNewer