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
// Does this code create 10000 live instances of MyObj before returning? | |
// Or will each one be released on the following iteration? | |
void foo() { | |
NSLog(@"Starting!"); | |
int i=0; | |
start: | |
id obj = [MyObj new]; | |
if (++i<10000) { | |
goto start; |
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
function fish_prompt --description 'Write out the prompt' | |
# Just calculate these once, to save a few cycles when displaying the prompt | |
if not set -q __fish_prompt_normal | |
set -g __fish_prompt_normal (set_color normal) | |
end | |
set -l delim '$' | |
switch $USER |
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
// | |
// DOXLabelWrapper.m | |
// Autolayout | |
// | |
// Created by BJ Homer on 7/11/14. | |
// Copyright (c) 2014 BJ Homer. All rights reserved. | |
// | |
#import "DOXLabelWrapper.h" |
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)keyDown:(NSEvent *)event | |
{ | |
unichar ch = [[event charactersIgnoringModifiers] characterAtIndex:0]; | |
if (ch == NSUpArrowFunctionKey && (event.modifierFlags & NSCommandKeyMask)) { | |
// Scroll to top | |
return; | |
} | |
else if (ch == NSDownArrowFunctionKey && (event.modifierFlags & NSCommandKeyMask)) { | |
// Scroll to bottom |
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
// Looking for a Swift replacement for the following ObjC code: | |
// id x = foo ?: bar | |
// | |
// Which of the following do you like, if any? Any other suggestions? | |
// (Note that '?' cannot be used in a custom operator.) | |
x = foo !|| bar | |
x = foo |< bar | |
x = foo ||< bar |
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
// You might think that a view could trigger window movement by overriding -[NSView mouseDownCanMoveWindow] | |
@interface DraggyView : NSView | |
@end | |
@implementation DraggyView | |
- (BOOL)mouseDownCanMoveWindow { | |
return YES; | |
} | |
@end |
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
@implementation MyImageView | |
- (void)registerForDraggedTypes:(NSArray *)newTypes { | |
if (self.editable) { | |
[super registerForDraggedTypes:newTypes]; | |
} | |
} | |
- (void)setEditable:(BOOL)editable | |
{ |
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
class Foo { | |
var closure: () -> () = {} | |
init() {} | |
func nothing() {} | |
func setupClosure() { | |
closure = { | |
[weak self] in | |
self?.nothing() // <-- this returns a "Void?", which means that the rhs's |
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
context | |
context | |
-AAAA | |
-AAAA | |
-AAAA | |
+BBBB | |
+BBBB | |
+BBBB | |
+BBBB | |
{ |
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
// What I would expect: | |
(lldb) p newPaths | |
([AnyObject]) $R1 = 2 values { | |
[0] = "This is a string", | |
[1] = "This is another string" | |
} | |