This file contains 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
__block NSNumber *val = [NSNumber numberWithInt:0]; | |
void (^blk)(void) = ^{ | |
__block NSNumber *val1 = val; | |
void (^blk2)(void) = ^{ | |
val1 = [NSNumber numberWithInt:1]; | |
}; | |
NSLog(@"val:%@ val1:%@", val, val1); | |
val = [NSNumber numberWithInt:2]; | |
NSLog(@"val:%@ val1:%@", val, val1); | |
val1 = [NSNumber numberWithInt:3]; |
This file contains 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
__block dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); | |
dispatch_async(queue, ^{ | |
// hogehoge | |
// ここに処理を書く | |
// | |
dispatch_semaphore_signal(semaphore); | |
}); | |
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); | |
dispatch_release(semaphore); |
This file contains 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
- (NSString*)base64:(NSData*)fromData { | |
static unsigned char base64Table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
const unsigned char *data = fromData.bytes; | |
char *buff = NSZoneMalloc(self.zone, fromData.length * 4 / 3 + 4); | |
int o = 0, i; | |
for (i = 0; i <= fromData.length; i++, o++) { | |
switch (i % 3) { | |
case 0: | |
if (i < fromData.length) { | |
buff[o] = base64Table[(data[i] >> 2) & 0x3f]; |
This file contains 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
// アニメーションの開始側 | |
// 予めanimationRemainに繰返し回数を入れておいてperformSelectorで呼びます | |
- (void)continueGadgetAnimating { | |
animationRemain --; | |
EasterEggView *image = [[[SnowGadget alloc] initWithImages:self.snowImages.subviews] autorelease]; | |
[self.touchView addSubview:image]; | |
[image startAnimating]; | |
if (animationRemain > 0) { | |
[self performSelector:@selector(continueGadgetAnimating) withObject:nil afterDelay:0.6f]; | |
} |
This file contains 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
#pragma mark - | |
#pragma mark animationScenario | |
// イメージを横長の領域に散らして配置したViewを作成する | |
- (id)initWithImages:(NSArray*)images { | |
if (self = [super init]) { | |
// Initialization code | |
NSLog(@"EasterEggImage initWithImage"); | |
int randVal = 0; | |
UIImageView *timage = nil; |
This file contains 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
#pragma mark - | |
#pragma mark ButtonAction // ボタンの応答 | |
// 写真ソース選択を出す | |
- (IBAction)pictAction:(id)sender { | |
NSLog(@"pictAction"); | |
[((TakePhotoView*)self.view) finderCloseForceAction:self]; | |
UIActionSheet *sheet = [UIActionSheet alloc]; | |
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ | |
if (self.appDelegate.sourceImage == nil) { | |
sheet = [[sheet initWithTitle:@"Select a Photo Source" delegate:self cancelButtonTitle:@"CANCEL" destructiveButtonTitle:nil otherButtonTitles:@"Built in Camera", @"Photo Albums", @"Camera Roll", nil] autorelease]; |
This file contains 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
{ | |
UIImagePickerController *controller = [[[UIImagePickerController alloc] init] autorelease]; | |
controller.sourceType = UIImagePickerControllerSourceTypeCamera; | |
controller.cameraOverlayView = self.cameraOverlay; | |
[self performSelector:@selector(removeOverlayView:) withObject:controller afterDelay:0.1f]; | |
controller.allowsEditing = YES; | |
controller.delegate = self; | |
// ニュッと出るのでは無く、フェードする | |
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; | |
[self presentModalViewController:controller animated:YES]; |