Adam Preble preble

View objc-bracing.md

Objective-C Bracing Style

I'm Adam Preble and this is the bracing style I like. Please don't use it unless you (a) like it, or (b) are contributing to a project of mine.

Rules

  • Braces go on the next line for:
    • Method definitions.
    • if blocks:
    • After case statements, but only if required by local variables within the case.
View gist:5306137
1 2 3 4 5 6 7 8
NSArray *things = ^{
NSMutableArray *tmpArray = [NSMutableArray arrayWithCapacity:numThings];
for (int i = 0; i < numThings; i++)
{
[tmpArray addObject: ... ];
}
return [tmpArray copy];
}();
View gist:5117339
View glerrcheck.h
1 2 3 4 5 6 7 8 9 10
// A macro I wrote a few years back to assist in checking OpenGL error codes.
// Add to a .h or at the top of your implementation file:
 
#define GLERR do {\
GLuint glerr;\
while((glerr = glGetError()) != GL_NO_ERROR)\
fprintf(stderr, "%s:%d glGetError() = 0x%04x", __FILE__, __LINE__, glerr);\
} while (0)
 
// Sprinkle in "GLERR;" after failure-prone OpenGL calls.
View RandomThreadSafetyTest.m
1 2 3 4 5 6 7 8 9 10
// Testing thread safety of rand() and random(); for more see:
// http://adampreble.net/blog/2012/09/mtrandom-an-objective-c-random-number-generator/
// Created by Adam Preble on 9/3/12
// Copyright (c) 2012 Adam Preble. All rights reserved.
//
 
#import <Foundation/Foundation.h>
 
#if 1
#define test_srandom srandom
View NSString+ConcurrentEnumeration.m
1 2 3 4 5 6 7 8 9 10
#import "NSString+ConcurrentEnumeration.h"
 
@implementation NSString (ConcurrentLineEnumeration)
 
- (void)enumerateConcurrentlyWithOptions:(NSStringEnumerationOptions)options
usingBlock:(void (^)(NSString *substring))block
{
dispatch_group_t group = dispatch_group_create();
[self enumerateSubstringsInRange:NSMakeRange(0, [self length])
View BGHUDTableViewHeaderCell.diff
1 2 3 4 5 6 7 8 9 10
Index: Framework/BGHUDTableViewHeaderCell.m
===================================================================
--- Framework/BGHUDTableViewHeaderCell.m
+++ Framework/BGHUDTableViewHeaderCell.m
@@ -73,7 +73,7 @@
}
- (void)_drawThemeContents:(NSRect)frame highlighted:(BOOL)flag inView:(id)view {
-
+
View BNRBlockView.h
1 2 3 4 5 6 7 8 9 10
@class BNRBlockView;
 
typedef void(^BNRBlockViewDrawer)(BNRBlockView *view, NSRect dirtyRect);
 
@interface BNRBlockView : NSView {
BNRBlockViewDrawer drawBlock;
BOOL opaque;
}
 
+ (BNRBlockView *)viewWithFrame:(NSRect)frame
View DMDTest.c
1 2 3 4 5 6 7 8 9 10
#include "WProgram.h"
void UpdateDMD();
void Bounce();
void SetAllDots(byte value);
void SetDot(byte col, byte row, byte value);
void FrameToSerial();
#define pinDisplayEnable 3 // DMD pin 1
#define pinRowData 4 // One pin 3
#define pinRowClock 5 // DMD pin 5
#define pinColLatch 6 // DMD pin 7
Something went wrong with that request. Please try again.