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
int class_count = objc_getClassList(nil, 0); | |
Class *buffer = calloc(class_count, sizeof(Class)); | |
if (buffer) { | |
//NSLog(@"allocated a %d bytes buffer",malloc_size(buffer)); | |
objc_getClassList(buffer,class_count); | |
//NSLog(@"total %i classes",class_count); | |
for (int i = 0; i < class_count; ++i) { | |
Class currClass = buffer[i]; | |
if ( class_respondsToSelector(currClass, @selector(conformsToProtocol:)) ) { | |
if ([currClass conformsToProtocol:@protocol(NSMutableCopying)]) { |
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
* thread #1: tid = 0x1c07, 0x0000000100040767 Memory Magic`-[TestString dealloc] + 23 at TestString.m:29, stop reason = breakpoint 1.1 | |
frame #0: 0x0000000100040767 Memory Magic`-[TestString dealloc] + 23 at TestString.m:29 | |
frame #1: 0x0000000100002a3c Memory Magic`-[MenuBar theEvent:] + 1116 at MenuBar.m:58 | |
frame #2: 0x00007fff85b5547a CoreFoundation`_CFXNotificationPost + 2554 | |
frame #3: 0x00007fff8ad0c846 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 64 | |
frame #4: 0x00000001000038d8 Memory Magic`-[MenuBarIcon memoryLoop] + 984 at MenuBarIcon.m:53 | |
frame #5: 0x0000000100003a22 Memory Magic`-[MenuBarIcon initWithFrame:] + 210 at MenuBarIcon.m:65 | |
frame #6: 0x00007fff82767148 AppKit`-[NSView init] + 62 | |
frame #7: 0x000000010000255e Memory Magic`-[MenuBar init] + 366 at MenuBar.m:25 | |
frame #8: 0x00007fff826abeca AppKit`-[NSCustomObject nibInstantiate] + 382 |
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
-(NSString*)execTask:(NSString*)launch args:(NSArray*)args | |
{ | |
if ([[NSFileManager defaultManager] isExecutableFileAtPath:launch] != YES){ | |
[bottomLeftLabel setStringValue:[NSString stringWithFormat:@"%@ not found",launch]]; | |
return nil; | |
} | |
NSPipe *stdout_pipe = [[NSPipe alloc] init]; |
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
[image setWantsLayer:YES]; | |
CALayer *flayer = [image layer]; | |
[flayer removeAllAnimations]; | |
[backImage setWantsLayer:YES]; | |
CALayer *blayer = [backImage layer]; | |
[blayer removeAllAnimations]; | |
NSView *superView = [image superview]; | |
[superView setWantsLayer:YES]; |
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
NSView *parent = [[NSView alloc] initWithFrame:NSZeroRect]; | |
NSView *child = [[NSView alloc] initWithFrame:NSZeroRect]; | |
[parent addSubview:child]; | |
[child setWantsLayer:YES]; | |
CALayer *childLayer = [child layer]; | |
CATransformLayer *transformLayer = [CATransformLayer layer]; | |
[transformLayer addSublayer:childLayer]; | |
[parent setWantsLayer:YES]; | |
NSLog(@"%@",childLayer); | |
NSLog(@"%@",transformLayer.sublayers); |
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
float lastTick = 0.0; | |
for (int i = 0; i <= 900; i++) { | |
float t = [self tickX:9 timesOfTotal:900 current:i lastTick:lastTick]; | |
if (t > 0) { | |
NSLog(@"%f %i",t,i); | |
lastTick = t; | |
} | |
} |
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 LaunchButton | |
- (id)initWithFrame:(NSRect)frame { | |
self = [super initWithFrame:frame]; | |
if (self) { | |
// Initialization code here. | |
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:NSZeroRect options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect owner:self userInfo:nil]; | |
[self addTrackingArea:area]; | |
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)mouseDown:(NSEvent*)event | |
{ | |
//create a NSPasteboardItem | |
NSPasteboardItem *pbItem = [NSPasteboardItem new]; | |
[pbItem setDataProvider:self forTypes:[NSArray arrayWithObjects:NSPasteboardTypeTIFF, nil]]; | |
//create a new NSDraggingItem with our pasteboard item. | |
NSDraggingItem *dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:pbItem]; | |
NSPoint dragPosition = [self convertPoint:[event locationInWindow] fromView:nil]; |
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
public func RegexValidationWithMessage(_ message:String, regex:String, allowingNull:Bool = true) -> Validation<String>? { | |
if let regex = try? NSRegularExpression(pattern: regex, options: .CaseInsensitive) { | |
return Validation<String>(message: message, validation: { (value) -> Bool in | |
let nullValidation = NonEmptyStringValidation("") | |
guard let stringValue = value else { | |
return false | |
} | |
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
//1 , cant be right as assigning instance variable does not make a copy | |
var fooBar = self.fooBar | |
fooBar.forEach({ foo in | |
if foo.id == bar.id { | |
fooBar.remove(at: fooBar.index(of: foo)!) | |
} | |
}) | |
self.fooBar = fooBar | |
//2, seems right as enumerated makes a copy |