Skip to content

Instantly share code, notes, and snippets.

>>> {}.get('foo', 123)
123
>>> {}.get('foo') or 123
123
>>> {'foo': []}.get('foo', 123)
[]
>>> {'foo': []}.get('foo') or 123
123
[backgroundView addSubview:imageView];
[backgroundView addSubview:[datasetView.subviews objectAtIndex:1]];
imageView.layer.masksToBounds = YES;
imageView.layer.cornerRadius = 15.;
backgroundView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds
cornerRadius:15.].CGPath;
backgroundView.layer.cornerRadius = 15.;
backgroundView.layer.shadowColor = [[UIColor colorWithWhite:0.0 alpha:1.] CGColor];
UILabel *label = [UILabel new];
label.text = locked ? @"🔒" : @"🔓";
UIBarButtonItem *lockBtn = [[UIBarButtonItem alloc] initWithCustomView:label];
lockBtn.tintColor = [UIColor redColor];
// UIBarButtonItem *lockBtn = [[UIBarButtonItem alloc] initWithTitle:title
// style:UIBarButtonItemStyleBordered
// target:nil action:nil];
NSMutableArray *rightBarButtonItems = [self.navigationItem.rightBarButtonItems mutableCopy];
[rightBarButtonItems insertObject:lockBtn atIndex:0];
self.navigationItem.rightBarButtonItems = rightBarButtonItems;
2011-11-16 12:46:58.567 smile[53799:707] nested push animation can result in corrupted navigation bar
2011-11-16 12:46:58.829 smile[53799:707] Unbalanced calls to begin/end appearance transitions for <RenderingViewController: 0x46bc10>.
2011-11-16 12:46:59.136 smile[53799:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
// EXC_BAD_ACCESS:
#0 0x35adfeda in objc_retain ()
#1 0x35aecbe4 in objc_retainAutoreleasedReturnValue ()
#2 0x0001165c in __block_global_2 (.block_descriptor=0xa9b08, tex1=0x438c60, tex2=0x337820) at /Users/dennda/dev/msc/pocs/Smile/Smile/Dataset.m:133
#3 0x3504174c in __CFSimpleMergeSort ()
#4 0x350417b4 in __CFSimpleMergeSort ()
#5 0x350417b4 in __CFSimpleMergeSort ()
#6 0x350417b4 in __CFSimpleMergeSort ()
#7 0x350417b4 in __CFSimpleMergeSort ()
+ (NSURL*)getDatasetRootFolder {
NSURL *appsupport = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
inDomain:NSUserDomainMask
appropriateForURL:nil
create:YES
error:nil];
NSURL *root = [appsupport URLByAppendingPathComponent:@"datasets" isDirectory:YES];
BOOL is_directory;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:root.absoluteString
isDirectory:&is_directory];
// For some reason (maybe ARC?) this doesn't work:
// [self.client respondToMessage:self];
// But this still works...
[self.client performSelector:@selector(respondToMessage:) withObject:self];
bplist00‘beT$topX$objectsX$versionY$archiver—aTrootħ
U$null‘ f[message_key]arguments_key\response_keyV$classÄÄ
#define MESSAGE_KEY @"message_key"
#define ARGUMENTS_KEY @"arguments_key"
#define RESPONSE_KEY @"response_key"
@implementation ...
@synthesize message=_message, arguments=_arguments, response=_response, client;
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super init];
UILabel *participants_label = [[UILabel alloc] init];
participants_label.text = @"Current Participants:";
participants_label.backgroundColor = [UIColor clearColor];
participants_label.font = [UIFont systemFontOfSize:28.];
[participants_label sizeToFit];
return participants_label;