extension Dictionary {
func map<U> (transform: Value -> U) -> Dictionary<Key, U> {
var result = Dictionary<Key, U>()
for (key, value) in self {
result[key] = transform(value)
}
return result
}
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
String returnString = "mystring"; | |
Writer writer = new QRCodeWriter(); | |
BitMatrix encoded = null; | |
try | |
{ | |
encoded = writer.encode(returnString, BarcodeFormat.QR_CODE, 300, 300); | |
} | |
catch (WriterException ex) |
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
class MainViewModel: NSObject { | |
var model :Meal[] = [] | |
let mealUrl = "http://verdant-upgrade-554.appspot.com/soservices/mealmanager" | |
init() { | |
super.init() | |
} | |
func fetchModel(completion:() -> Void) { |
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
public class BinaryNode<T: Comparable>: Comparable { | |
var value: T | |
var left: BinaryNode<T>? | |
var right: BinaryNode<T>? | |
init(value: T) { | |
self.value = value | |
} | |
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
public class Box<T> { | |
let unbox: T | |
init(_ value: T) { self.unbox = value } | |
} | |
public enum ResultType<T> { | |
case Success(Box<T>) | |
case Error(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
// | |
// TableViewController.swift | |
// TableViewExpansions | |
// | |
// Created by Vesza Jozsef on 05/05/15. | |
// Copyright (c) 2015 Vesza Jozsef. All rights reserved. | |
// | |
import UIKit |
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
public static IEnumerable<T> FindVisualChildren<T>(this DependencyObject e) where T : DependencyObject | |
{ | |
if (e == null) yield break; | |
VisualTreeHelper.GetChildren(e).Filter(child is T).Map(child => () | |
{ | |
if (children != null) | |
{ | |
yield return children; | |
} |
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 BaseRequirements { | |
// List common requirements here. | |
} | |
protocol AdditionalRequirements { | |
// Any additional reqs here. | |
} | |
struct BasicType: BaseRequirements { | |
// I will only do the basics. |
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 | |
var array = [AnyObject]() | |
array.append(1) | |
array.append(2.0) | |
array.append("3") | |
array.append([4, 5, 6]) | |
array.append([7: "7", 8: "8"]) | |
// prints "true" |
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
private func handleContentChange() { | |
let tableViewHeight = CGFloat(subViewModel.count()) * rowHeight | |
let contentHeight = standardPadding + segmentedControlHeight.constant + standardPadding + tableViewHeight + standardPadding + openButtonHeight.constant + standardPadding | |
dispatch_async(dispatch_get_main_queue()) { | |
self.tableView.reloadData() | |
self.preferredContentSize.height = contentHeight | |
} |
OlderNewer