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 Array { | |
func twoAtATime(block: ((f: T, s: T))->()) { | |
var _first: T? = nil | |
var _second: T? = nil | |
for e:T in self { | |
_first = _second | |
_second = e | |
if _first != nil && _second != nil { |
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 NSString { | |
func toDateWithFormatter(dateFormatter: NSDateFormatter) -> NSDate? { | |
return dateFormatter.dateFromString(self) | |
} | |
} |
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 Cocoa | |
infix operator ||= {} | |
func ||= <T> (inout value: T?, newValue: @autoclosure () -> T) -> T { | |
if value == nil { | |
value = newValue() | |
} | |
return 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
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) | |
{ | |
if let vc = segue.destinationViewController as? CreateNoteViewController { | |
println("Create Note VC") | |
} | |
if let vc = segue.destinationViewController as? SingleNoteViewController { | |
println("Show single note") | |
} | |
} |
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 Person { | |
class func classString() -> String { | |
return NSStringFromClass(self) | |
} | |
} | |
Person.classString() // "_TtC11lldb_expr_06Person" |
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
ALAssetRepresentation *rep = [asset defaultRepresentation]; | |
NSDictionary *dict = [rep metadata]; | |
NSString *xmp = dict[@"AdjustmentXMP"]; | |
NSData *xmpData = [xmp dataUsingEncoding:NSUTF8StringEncoding]; | |
NSError *e = nil; | |
NSArray *filters = [CIFilter filterArrayFromSerializedXMP:xmpData inputImageExtent:CGRectZero error:&e]; | |
CIFilter *filter = [filters firstObject]; | |
CIImage *image =[CIImage imageWithCGImage: [rep fullScreenImage]]; | |
[filter setValue:image forKey:kCIInputImageKey]; |
NewerOlder