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 --analyze readonly-property-analyzer.m | |
readonly-property-analyzer.m:20:2: warning: Incorrect decrement of the reference count of an object that is not owned at this point by the caller | |
[_string release]; | |
^~~~~~~~~~~~~~~~~ | |
1 warning generated. |
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/Cocoa.h> | |
/* | |
clang -fobjc-arc -Wall preview-from-url.m -o /tmp/preview-from-url -framework Cocoa | |
When run on a file in my iCloud Drive: | |
2015-01-08 16:39:54.008 preview-from-url[23221:261259] NSURLThumbnailDictionaryKey = { | |
NSThumbnail1024x1024SizeKey = "<NSImage 0x7fd6b34228f0 Size={790, 1024} Reps=(\n \"<NSCGImageSnapshotRep:0x7fd6b34249e0 cgImage=<CGImage 0x7fd6b3423de0>>\"\n)>"; | |
} |
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
/* | |
Radar 18996669: Swift: Attempting to instantiate instance via class pointer crashes | |
% xcrun -sdk macosx swiftc instantiate-from-class.swift | |
0 swift 0x0000000107668b68 llvm::sys::PrintStackTrace(__sFILE*) + 40 | |
1 swift 0x0000000107669054 SignalHandler(int) + 452 | |
2 libsystem_platform.dylib 0x00007fff95c74f1a _sigtramp + 26 | |
3 libsystem_platform.dylib 0x0000000108bd3e00 _sigtramp + 1928720128 | |
4 swift 0x0000000107a675fc collectFullName(swift::ArchetypeType const*, llvm::SmallVectorImpl<char>&) + 92 | |
5 swift 0x0000000107a675c8 collectFullName(swift::ArchetypeType const*, llvm::SmallVectorImpl<char>&) + 40 |
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 |
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
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
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
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
/* | |
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
#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[]) | |
{ |