Skip to content

Instantly share code, notes, and snippets.

View KatagiriSo's full-sized avatar

KatagiriSo KatagiriSo

View GitHub Profile
@KatagiriSo
KatagiriSo / SimpleFrameProperty
Created December 21, 2011 04:11
Simple Frame Property
// Simple Frame Property
@interface UIView(FrameUtil)
@property (nonatomic,assign) float originX;
@property (nonatomic,assign) float originY;
@property (nonatomic,assign) float width;
@property (nonatomic,assign) float height;
@property (nonatomic,assign) CGSize size;
@property (nonatomic,assign) CGPoint origin;
@end
@KatagiriSo
KatagiriSo / gist:1520647
Created December 26, 2011 06:53
variable argument method
#import <stdarg.h>
void myLog(NSString *message,...);
@interface ViewController : UIViewController
- (void)myLog:(NSString *)message,... NS_REQUIRES_NIL_TERMINATION;
@end
void myLog(NSString *message,...) {
va_list list;
@KatagiriSo
KatagiriSo / gist:1522593
Created December 27, 2011 02:59
NSTask
NSTask *task = [[NSTask alloc] init];
NSPipe *pipe = [[NSPipe alloc] init];
[task setStandardOutput:pipe];
NSString *launchPath = @"/Applications/Preview.app/Contents/MacOS/Preview";
NSArray *args_ = [NSArray arrayWithObjects:@"/Users/katagiriso/Documents/tmp.pdf",nil];
[task setLaunchPath:launchPath];
[task setArguments:args_];
@KatagiriSo
KatagiriSo / gist:1522762
Created December 27, 2011 04:58
Animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self setFrame:CGRectMake(moveToPoint.x, moveToPoint.y, self.frame.size.width, self.frame.size.height)];
[UIView commitAnimations];
@KatagiriSo
KatagiriSo / gist:1525690
Created December 28, 2011 01:12
setColor
- (void)setColor:(UIView *)v
{
static int i = 0;
NSArray* colors = [NSArray arrayWithObjects:[UIColor redColor],[UIColor blueColor],[UIColor yellowColor],[UIColor greenColor],[UIColor purpleColor],[UIColor blackColor],[UIColor lightGrayColor],nil];
[v setBackgroundColor:[colors objectAtIndex:i]];
i++;
if (i>= [colors count]) {
i = 0;
}
}
@KatagiriSo
KatagiriSo / gist:1526734
Created December 28, 2011 06:30
GetFileName
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSArray *names = [[NSFileManager defaultManager] directoryContentsAtPath:resourcePath];
@KatagiriSo
KatagiriSo / file0.m
Created December 2, 2013 12:33
NSNumberでのよくやった間違い ref: http://qiita.com/KatagiriSo/items/49f55e733a0f6d4fe3c9
if (num != 0) {...}
time_t start, end;
start = clock();
...
end = clock();
NSLog(@" => time %ld",test,(end - start));
// オフセットが変換した(スクロールした)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
// ズームした
- (void)scrollViewDidZoom:(UIScrollView *)scrollView NS_AVAILABLE_IOS(3_2);
// ドラッグがはじまっった。
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
<html>
<head>
<title>Sample</title>
</head>
<body>
<script type="text/javascript">
<!--
dd = new Date();
document.write(dd.toLocaleString());
// -->