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/Foundation.h> | |
/* | |
clang -fobjc-arc -O2 -Wall write-file-by-merging.m -o write-file-by-merging -framework Foundation | |
echo qq > $HOME/Desktop/qq.txt | |
open -e $HOME/Desktop/qq.txt | |
then: | |
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/Foundation.h> | |
/* | |
clang -Wall -O2 -fobjc-arc NSURLEncodingCase.m -framework Foundation -o NSURLEncodingCase | |
./NSURLEncodingCase 'https://localhost/test%5b' 'https://localhost/test%5B' | |
2013-03-18 11:04:42.663 NSURLEncodingCase[80520:707] https://localhost/test%5b is NOT equal https://localhost/test%5B | |
http://tools.ietf.org/html/rfc3986#section-2.1 says |
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
{ | |
"graph" : { | |
"title" : "OmniPresence", | |
"datasequences" : [ | |
{ | |
"title" : "Hours per Crash", | |
"datapoints" : [ | |
{ | |
"title" : "2013-02-18", | |
"value" : 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 <Foundation/Foundation.h> | |
#include <sys/stat.h> | |
/* | |
clang -Wall -O2 -fobjc-arc directory-url-unencoded.m -o directory-url-unencoded -framework Foundation | |
*/ | |
int main(int argc, char *argv[]) | |
{ |
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
/* | |
xcrun swiftc -c switch-enum-struct-case.swift | |
switch-enum-struct-case.swift:30:36: error: '(size: Size)' does not have a member named 'width' | |
println("rectangle with size \(size.width)x\(size.height)") | |
^ ~~~~~ | |
*/ | |
struct Size { |
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
convenience public init?(url:NSURL, error:NSErrorPointer) { | |
if let data = NSData(contentsOfURL:url, options: NSDataReadingOptions(0), error: error) { | |
self.init(data:data) | |
} else { | |
return nil; | |
} | |
} | |
--> all stored properties of a class instance must be initialized before returning nil from an initializer |
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 protocol MeasurementUnit { | |
// If we have one of this unit, how many millimeters is it? | |
class var asMillimeters: Double { get } | |
} | |
public class Inch : MeasurementUnit { | |
public class var asMillimeters: Double { | |
get { | |
return 25.4 | |
} | |
} |
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 protocol MeasurementUnit { | |
// If we have one of this unit, how many millimeters is it? | |
class var asMillimeters: Double { get } | |
} | |
public class Millimeter : MeasurementUnit { | |
public class var asMillimeters: Double { | |
get { | |
return 1.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 Foundation | |
@objc protocol MeasurementUnit { | |
// If we have one of this unit, how many millimeters is it? | |
class var asMillimeters: Double { get } | |
var value: Double { get } | |
init(_:Double) | |
} |
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
/* | |
Subclassing a FloatLiteralConvertible conforming class and then using the convertible bit uses the superclass initializer, even when the subclass type is specified explicitly. | |
% xcrun -sdk macosx swiftc ./subclass-float-literal.swift | |
% ./subclass-float-literal | |
b1 className = B | |
b1 = B | |
b2 className = A | |
assertion failed: Must be subclassed: file ./subclass-float-literal.swift, line 23 |