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 Foundation | |
extension Array | |
{ | |
/** Randomizes the order of an array's elements. */ | |
mutating func shuffle() | |
{ | |
for _ in 0..<10 | |
{ | |
sort { (_,_) in arc4random() < arc4random() } |
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
__weak id weakSelf = self; | |
void (^aBlock)(void) = ^{ | |
<MyClass> *strongSelf = weakSelf; | |
if (strongSelf) | |
{ | |
// strongSelf->someIvar = 42; | |
// [strongSelf someMethod]; | |
} | |
}; |
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
// This code assumes that ARC is enabled. | |
// Returns the size of this View in its NIB. | |
+ (CGSize)preferredSize | |
{ | |
static NSValue *sizeBox = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// Assumption: The XIB file name matches this UIView subclass name. | |
UINib *nib = [UINib nibWithNibName:NSStringFromClass(self) bundle:nil]; |
NewerOlder