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
* 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
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
NSString *foo = @"foo"; | |
NSString *bar = [NSString stringWithString:@"bar"]; | |
NSString *baz = [[NSString alloc] initWithString:@"baz"]; | |
NSMutableString *bax = [NSMutableString stringWithString:@"bax"]; | |
NSData *objData = [NSData dataWithBytes:foo length:malloc_size(foo)]; | |
NSLog(@"%s foo contains %@, hash %lu, retain %i",class_getName(object_getClass(foo)),objData,[foo hash],[foo retainCount]); | |
objData = [NSData dataWithBytes:bar length:malloc_size(bar)]; | |
NSLog(@"%s bar contains %@, hash %lu, retain %i",class_getName(object_getClass(bar)),objData,[bar hash],[bar retainCount]); |
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
@interface AppDelegate : NSObject <NSApplicationDelegate> { | |
NSMutableString *retainedProperty; //explicitly declaring ivar backing is only required for the 32 bit runtime, is automatically added by the compiler for 64 bit | |
} | |
@property (retain) NSMutableString *retainedProperty; | |
@end | |
@implementation AppDelegate |
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
NSMutableArray *ivarPrevious = [NSMutableArray arrayWithCapacity:1]; | |
-(void)foo | |
{ | |
NSMutableArray *newivarPrevious = [NSMutableArray arrayWithCapacity:1]; | |
for (...){ | |
NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:1]; | |
[ret setObject:foo forKey:@"foo"]; | |
[ret setObject:bar forKey:@"bar"]; | |
[newivarPrevious addObject:[ret description]]; |
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 "DetailsDataSource.h" | |
@implementation DetailsDataSource | |
@synthesize rootItems; | |
- (id)init | |
{ | |
self = [super 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
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | |
//create a example nested dictionary with just 4 levels | |
NSMutableDictionary *parent = [[[NSMutableDictionary alloc] init] autorelease]; | |
NSDictionary *thirdChild = [NSDictionary dictionaryWithObjectsAndKeys:@"bi",@"l4",@"nar",@"l4_", nil]; | |
NSDictionary *secondChild = [NSDictionary dictionaryWithObjectsAndKeys:thirdChild,@"l3",@"bar",@"l3_", nil]; | |
NSDictionary *firstChild = [NSDictionary dictionaryWithObjectsAndKeys:secondChild,@"l2",secondChild,@"l2_", nil]; | |
[parent setObject:firstChild forKey:@"l1"]; | |
[parent setObject:firstChild forKey:@"l1_"]; | |
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
@interface VAImage : UIView <VAUrlConnectionDelegate> { | |
VAUrlConnection *conn; | |
} | |
- (void) connectionDidFinish:(VAUrlConnection *)theConnection; | |
@implementation VAImage |
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
NSArray *sortedFirstNames = [firstNames sortedArrayUsingFunction:familyNameCompare context:NULL]; | |
NSInteger familyNameCompare(NSString *one, NSString *two, void *context) | |
{ | |
NSArray *sortedFamilyNames = [[FirstNamesAndFamilyNames allValues] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; | |
NSString *oneName = [FirstNamesAndFamilyNames objectForKey:one]; | |
NSString *twoName = [FirstNamesAndFamilyNames objectForKey:two]; |