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
- (void)setArray:(NSArray *)anArray | |
{ | |
_myArray = anArray; // aha! subtle bug because anArray MAY be a mutable array, so you need to do [anArray copy]. With the magic of inheritance, the type system becomes confusingly worthless, telling you that yes, a mutable array is an immutable array. Yay for confusing first time programmers! | |
} | |
// This problem exists EVERYWHERE: | |
- (void)doSomethingWithView:(NSView *)aView | |
{ | |
[aView addSubview:controlView]; // This may or may not work depending what aView is. Despite the docs telling you that addSubview is a perfectly fine PUBLIC API, subclasses of NSView may make it effectively private, thus breaking here. So what's the point of saying "give me a view" if subclasses of NSView can willy-nilly change the exposed API? |
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
Given object X | |
Given type A | |
if X isa A, BUT X.m isnot A::m | |
then I am unhappy. | |
For example (classical): | |
class A { func one() { return 1 } } | |
class B : A { func one() { return 2 } } |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
[importButton setBordered:NO]; | |
[importButton setImagePosition:CPImageLeft]; | |
[importButton setTitle:@"blah"]; | |
[importButton setTextColor:[CPColor blackColor]]; | |
[importButton setFont:[CPFont systemFontOfSize:16.0]]; | |
[importButton setImage:[[CPImage alloc] initWithContentsOfFile:path1 size:CGSizeMake(32.0, 32.0)]]; | |
[importButton setAlternateImage:[[CPImage alloc] initWithContentsOfFile:path2 size:CGSizeMake(32.0, 32.0)]]; | |
[importButton setAlignment:CPLeftTextAlignment]; | |
[importButton setDelegate: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
@implementation TheCell : CPView | |
{ | |
id myRepresentedObject | |
} | |
- (void)mouseDragged:(CPEvent)anEvent | |
{ | |
var dragView = [[TheCell alloc] initWithFrame:[self bounds]]; | |
[dragView setRepresentedObject:myRepresentedObject]; | |
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
- (CPString)stringByDeletingLastPathComponent | |
{ | |
var path = self, | |
start = length - 1; | |
while (path.charAt(start) === '/') | |
start--; | |
path = path.substr(0, path.lastIndexOf('/', start)); | |
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
for(; index < count; ++index) | |
{ | |
var lhs = self[index], | |
rhs = anArray[index]; | |
if (lhs === rhs || lhs.isa && rhs.isa && [lhs isEqual:rhs]) | |
continue; | |
return NO; | |
} |
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
for(; index < count; ++index) | |
{ | |
var lhs = self[index], | |
rhs = anArray[index]; | |
if (lhs !== rhs && (!lhs.isa || !rhs.isa || ![lhs isEqual:rhs])) | |
return NO; | |
} |
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
--- a/Foundation/CPTimer.j | |
+++ b/Foundation/CPTimer.j | |
@@ -243,13 +243,13 @@ var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functio | |
theFunction = nil; | |
if (typeof codeOrFunction === "string") | |
- theFunction = function() { new Function(codeOrFunction)(); CPTimersForTimeoutIDs[timeoutID] = nil; } | |
+ theFunction = function() { new Function(codeOrFunction)(); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; } | |
else | |
{ |