Skip to content

Instantly share code, notes, and snippets.

@edom18
edom18 / EntityMigrationPolicySample.m
Created February 5, 2014 12:07
CoreDataのマイグレーションをしようとしたときのメモ(未解決あり) ref: http://qiita.com/edo_m18/items/717fe32d744a10df7179
- (BOOL)createDestinationInstancesForSourceInstance:(NSManagedObject *)sInstance entityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
{
NSManagedObjectContext *context = [manager destinationContext];
NSString *entityName [mapping destinationEntityName];
NSManagedObject *dInstance = [NSEntityDescription insertNewObjectForEntityForName:entityName inManagedObjectContext:context];
[dInstance setValue:@"value1" forKey:@"anyKey1"];
[dInstance setValue:@"value2" forKey:@"anyKey2"];
//…
//レイヤーを新規作成
CALayer *sublayer = [CALayer layer];
sublayer.backgroundColor = [UIColor blueColor].CGColor;
sublayer.shadowOffset = CGSizeMake(0, 3);
sublayer.shadowRadius = 5.0;
sublayer.shadowColor = [UIColor blackColor].CGColor;
sublayer.shadowOpacity = 0.8;
sublayer.frame = CGRectMake(30, 30, 120, 150);
sublayer.borderColor = [UIColor blackColor].CGColor;
sublayer.borderWidth = 2.0;
@edom18
edom18 / file0.m
Created February 23, 2014 16:10
[Objective-C] AVCaptureとvImageを使ってリアルタイムフィルタを作ってみる ref: http://qiita.com/edo_m18/items/727bee5affe6e36d77c2
#import <Accelerate/Accelerate.h>
#import <AVFoundation/AVFoundation.h>
@edom18
edom18 / file0.m
Created February 27, 2014 01:57
[Objective-C] Blocksがややこいのでまとめてみる ref: http://qiita.com/edo_m18/items/a1ee24cd23d3adde51d8
void (^blk)(void) { NSLog(@"in block"); };
@edom18
edom18 / file0.m
Created March 1, 2014 14:18
[Objective-C] フリップアニメーションでビューを切り替える ref: http://qiita.com/edo_m18/items/45fcbc67154eb68ef469
UIView *view1 = [[UIView alloc] initWithFrame:self.view.bounds];
view1.backgroundColor = [UIColor redColor];
UIView *view2 = [[UIView alloc] initWithFrame:self.view.bounds];
view2.backgroundColor = [UIColor blueColor];
[self.view addSubview:view1];
[self.view addSubview:view2];
// 追加と同時に行うとアニメーションしないので、サンプルでは処理をちょっとだけ遅延させています
@edom18
edom18 / file0.m
Created March 5, 2014 15:19
AppleのCore Animationプログラミングガイドを読んだメモ ref: http://qiita.com/edo_m18/items/4309d01b67ee42c35b3c
// `CAEAGLLayer`を返す例
+ (Class) layerClass
{
return [CAEAGLLayer class];
}
@edom18
edom18 / file0.m
Created March 6, 2014 12:22
[Objective-C] UIViewをいい感じに上下左右センタリングする ref: http://qiita.com/edo_m18/items/5dd48b7ee1e6899b8ed5
// ベースのビュー(これをセンタリングする)
UIView *baseView = [[UIView alloc] init];
[baseView addSubview:label];
// アイコンビュー
UIImage image = [UIImage imageNamed:@"hoge"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[baseView addSubview:imageView];
@edom18
edom18 / file0.m
Created March 9, 2014 16:26
NSDataの中身を確認する方法 ref: http://qiita.com/edo_m18/items/b39fa31cd5c094fd05b6
NSLog(@"%@", [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding]);
@edom18
edom18 / file0.m
Created March 15, 2014 14:12
[Objective-C] UIViewControllerの回転を自力でやる ref: http://qiita.com/edo_m18/items/e312667396f3b49b1dbe
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
UIWindow *window = nil;
if ([appDelegate respondsToSelector:@selector(window)]) {
window = [appDelegate window];
}
else {
window = [[UIApplication sharedApplication] keyWindow];
}
@edom18
edom18 / file0.m
Created March 17, 2014 14:51
[Objective-C] Swizzling(ランタイムAPI)を使ってDebugをしやすくする ref: http://qiita.com/edo_m18/items/9c57f4714d5c14a990c4
@interface NSString (sample)
- (NSString *)swapLowercaseString;
@end
////////////////////////////////////////
@implementation NSString (sample)