This file contains hidden or 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
void f(void) { | |
char *CArray[] = { // correct! | |
"a", | |
"b", | |
"c" | |
}; | |
CGRect CInitializer = { // correct! | |
.origin = { | |
0, | |
0 |
This file contains hidden or 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
>>> from Foundation import * | |
>>> NSJSONSerialization | |
<objective-c class NSJSONSerialization at 0x7fff759b0c88> | |
>>> NSJSONSerialization.JSONObjectWithData_options_error_(NSData.data(), 0, None) | |
>>> stream = NSInputStream.inputStreamWithData_(NSData.data()) | |
>>> stream.open() | |
>>> NSJSONSerialization.JSONObjectWithStream_options_error_(stream, 0, None) | |
...and here it just hangs forever... |
This file contains hidden or 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
#if OBJC | |
@interface MyThingy : NSObject { | |
#else | |
struct MyThingy { | |
#endif | |
int field1; | |
char *field2; |
This file contains hidden or 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 Lookuper { | |
func get<T: NSObject>(key: String) -> T? | |
} | |
struct KeyError { | |
var key: String | |
var desiredType: NSObject.Type | |
var actualType: Any.Type | |
func simpleDescription() -> String { |
This file contains hidden or 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
#!/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -i -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk | |
import Foundation | |
class JSON { | |
struct Path: Printable { | |
enum Element { | |
case Index(Int) | |
case Key(String) |
This file contains hidden or 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
#!/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -i -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk | |
import Foundation | |
class JSON { | |
struct Path: Printable { | |
enum Element { | |
case Index(Int) | |
case Key(String) |
This file contains hidden or 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
let oddnumbers = generator { | |
let i = 1 | |
body({ | |
return i | |
}, { | |
i += 2 | |
} | |
} | |
for x in oddnumbers() { |
This file contains hidden or 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> | |
NSDictionary *TestD(void) { | |
return @{ | |
@"string" : @"abc", | |
@"number" : @42, | |
@"dictionary" : @{ | |
@"string" : @"abcdef", | |
@"array" : @[ @"a", @2 ] | |
}, |
This file contains hidden or 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
MikeBookPro:~/shell mikeash$ ./memory.swift | |
<NSObject: 0x7faae4837bc0> | |
0 0x00007fff5567d470: 64 bytes <unknwn> c07b83e4aa7f00006133dd8bff7f000060f58c0e01000000c07b83e4aa7f000090f48c0e010000004c7fdb8bff7f000060f58c0e01000000c07b83e4aa7f0000 | |
( 0, 0x00007fff5567d470@0 ) <- 1 0x00007faae4837bc0: 16 bytes <malloc> 1078fe76ff7f00000000000000000000 | |
( 0, 0x00007fff5567d470@8 ) <- 2 0x00007fff8bdd3361: 64 bytes <unknwn> eb0e4c89ff4c89f6e8e7c5feff4989c74c89f84883c4105b415c415e415f5dc3b801000000c3554889e5e87ef2ffff0fb6c05dc331c0c3554889e5e819f3ffff -- strings: ([A\A^A_] ) | |
( 0, 0x00007fff5567d470@16 ) <- 3 0x000000010e8cf560: 64 bytes <unknwn> 554889e541574156534883ec284989fe41f646200174084c89f3e9a90100004c8975c84c8b3d762b03004c89ffe842160100488d45c8488945d0c745d8010000 -- strings: (AWAVSH ) | |
( 0, 0x00007fff5567d470@32 ) <- 4 0x000000010e8cf490: 64 bytes <unknwn> 554889e54883ec10488975f8488d75f8e82bfdffff4883c4105dc30f1f440000554889e54883ec10488975f0488955f8488d75f0e807fdf |
This file contains hidden or 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 Endianness { | |
case Big | |
case Little | |
func swapWithNative(slice: Slice<UInt8>) -> Slice<UInt8> { | |
#if true | |
let native = Little | |
#else | |
let native = Big | |
#endif |
OlderNewer