Skip to content

Instantly share code, notes, and snippets.

- (IBAction)buttonPressed:(id)sender {
if (timer == nil) {
seconds = 30;
timer = [[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateCounter:)
userInfo:nil
repeats:YES] retain];
}
}
// Version 1
[[self.scrollView subviews] enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
[UIView animateWithDuration:0.25 animations:^{
obj.alpha = 0.0;
} completion:^(BOOL finished) {
[obj removeFromSuperview];
}];
}];
// Version 2
[[self.scrollView subviews] enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
[UIView animateWithDuration:0.25 animations:^{
obj.alpha = 0.0;
} completion:^(BOOL finished) {
[obj removeFromSuperview];
}];
}];
// Use debugLog() or debugLogPretty() to log messages to the console when the "Debug" configuration
// is used to build the project - these logging messages won't appear in a Release build.
//
// Use assertLog() for more serious conditions. On Debug builds, assertLog() will throw an assertion
// and on Release builds it will turn into a standard NSLog (in case it comes to digging through a user's
// device logs to fix something)
#ifdef DEBUG
#define _D(...) __VA_ARGS__
#define debugLog(fmt, ...) NSLog(fmt, ##__VA_ARGS__)
#define debugLogPretty(fmt, ...) NSLog(@"%s (%@:%d)\n%@", \
CATransition *transition = [CATransition animation];
transition.duration = 0.25f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[button.layer addAnimation:transition forKey:nil];
+ (void)initialize {
if (self == [AppDataBase class]) {
void (^dateAccessorFactory)(NSString*,NSString*) = ^(NSString *key, NSString *strKey) {
void(^setterBlock)(id,NSDate*) = [^void(id self, NSDate *val) {
[self willChangeValueForKey:key];
[self setPrimitiveValue:val forKey:key];
[self setPrimitiveValue:nil forKey:strKey];
[self didChangeValueForKey:key];
} copy];
// Works
if (self.currentScope == 1) {
cell.contentViewInsets = UIEdgeInsetsMake(0, 0, 0, 2);
} else {
cell.contentViewInsets = UIEdgeInsetsZero;
}
// Works
UIEdgeInsets inset = (self.currentScope == 1) ? UIEdgeInsetsMake(0, 0, 0, 2) : UIEdgeInsetsZero;
cell.contentViewInsets = inset;
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
UITableViewCell *cell = nil;
if ([indexPath isEqual:[tableView indexPathForSelectedRow]]) {
cell = [tableView dequeueReusableCellWithIdentifier:@"SelectedCell"];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SelectedCell"] autorelease];
// Do any one-time setup for the cell here, like creating subviews you want to add to the cell
UIView *specialSelectedView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
specialSelectedView.backgroundColor = [UIColor redColor];
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
UITableViewCell *cell = nil;
if ([indexPath isEqual:[tableView indexPathForSelectedRow]]) {
cell = [tableView dequeueReusableCellWithIdentifier:@"SelectedCell"];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SelectedCell"] autorelease];
// Do any one-time setup for the cell here, like creating subviews you want to add to the cell
UIView *specialSelectedView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
specialSelectedView.backgroundColor = [UIColor redColor];
@sbrocket
sbrocket / uncrustify_OBJC.cfg
Created February 5, 2011 08:21
An uncrustify configuration for Objective-C
indent_align_string=false
indent_braces=false
indent_braces_no_func=false
indent_brace_parent=false
indent_namespace=false
indent_extern=false
indent_class=false
indent_class_colon=false
indent_else_if=false
indent_func_call_param=false