Skip to content

Instantly share code, notes, and snippets.

[[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 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
- (IBAction)buttonPressed:(id)sender {
if (timer == nil) {
seconds = 30;
timer = [[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateCounter:)
userInfo:nil
repeats:YES] retain];
}
}
// 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%@", \
final section layout:
__TEXT/__text addr=0x00002000, size=0x000C802C, fileOffset=0x00001000, type=1
__TEXT/__stub_helper addr=0x000CA02C, size=0x0000102C, fileOffset=0x000C902C, type=31
__TEXT/__gcc_except_tab addr=0x000CB058, size=0x00000906, fileOffset=0x000CA058, type=0
__TEXT/__cstring addr=0x000CB960, size=0x00035F3D, fileOffset=0x000CA960, type=12
__TEXT/__const addr=0x001018A0, size=0x00000270, fileOffset=0x001008A0, type=0
__TEXT/__ustring addr=0x00101B10, size=0x00000002, fileOffset=0x00100B10, type=15
__TEXT/__symbolstub1 addr=0x00101B14, size=0x00000558, fileOffset=0x00100B14, type=34
__DATA/__lazy_symbol addr=0x00103000, size=0x00000558, fileOffset=0x00102000, type=35
__DATA/__program_vars addr=0x00103558, size=0x00000014, fileOffset=0x00102558, type=29
// This in the .pch file...
#ifdef DEBUG
#elseif
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#endif
// ..causes this to generate a compiler error.
// Use of undeclared identifier 'derp'
- (void)transitionToNewRootViewController:(UIViewController *)newRootVC animated:(BOOL)animated moveToLeft:(BOOL)moveToLeft {
UIViewController *rootVC = self.window.rootViewController;
if (rootVC == newRootVC) {
return;
}
CGFloat direction = (moveToLeft) ? 1 : -1;
CGRect initialFromFrame = rootVC.view.frame;
CGRect initialToFrame = initialFromFrame;
NSError *error = nil;
if (![self myMethodThatCanFail:&error]) {
NSLog(@"%@", error);
}
////////
- (BOOL)myMethodThatCanFail:(NSError **)errorPtr {
// This method sucks so much that it always fails :(
if (errorPtr != NULL) {
// Uses a private internal subclass to allow for loading the view from within a NIB.
// The subclass allows us to break the initialization loop that would otherwise occur.
@interface SomeMyView__ : SomeMyView {
}
@end
@implementation SomeMyView
+ (SomeMyView*)loadFromNib {
@interface A : NSObject
- (NSDictionary *)someDictionaryForSomething;
@end
@interface B : A
@end
@implementation B