Skip to content

Instantly share code, notes, and snippets.

@tamaki-shingo
tamaki-shingo / gist:2848813
Created June 1, 2012 04:38
文字列に合わせたCGSizeを取得
NSString* text = @"hoge";
CGSize size = CGSizeMake(380, CGFLOAT_MAX);
CGSize textSize = [text sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeCharacterWrap];
NSLog(@"textSize.height is %f",textSize.height);
@tamaki-shingo
tamaki-shingo / gist:2946527
Created June 18, 2012 02:38
NSLogでCGRectを一発表示させる
CGRect frame = view.frame;
NSLog(@"%@",NSStringFromCGRect(frame));
@tamaki-shingo
tamaki-shingo / gist:4065221
Created November 13, 2012 11:02
dispatch_once関数を使ったSingletonパターンの実装(dispatch_onceの入力でsnippet出る)
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
<#code to be executed once#>
});
#ifdef DEBUG
#define LOG(...) NSLog(__VA_ARGS__)
#else
#define LOG(...) ;
#endif
#ifdef DEBUG
#define LINE() NSLog(@"%d",__LINE__)
#else
#define LINE() ;
@tamaki-shingo
tamaki-shingo / gist:5532784
Created May 7, 2013 13:59
プロトコルがサポートされているか確認する
if ([[UIImageView class] conformsToProtocol:@protocol(NSCopying)])
{
NSLog(@"NSCopying protocol supported");
}else{
NSLog(@"中に誰もいませんよ?");
}
@tamaki-shingo
tamaki-shingo / gist:5532822
Created May 7, 2013 14:06
対象オブジェクトに特定のメソッドが存在するかを確認する。
if ([hogeImageView respondsToSelector:@selector(copyWithZone:)]) {
LOG(@"王大人,copyWithZoneメソッド確認!");
}else{
LOG(@"お前のcopyWithZone:ねーから!wwww");
}
@tamaki-shingo
tamaki-shingo / SearchStrings shell
Created June 26, 2013 03:16
特定の文字列を複数テキスト内から検索する
find . -name "*.m" -type f -print | xargs grep "hoge" - n -5 > RESULT.txt
@tamaki-shingo
tamaki-shingo / gist:6086930
Created July 26, 2013 07:21
特定のフォルダ内のファイル数数えたい時〜(例は*.mファイルね)
find . -name "*.m" -type f | wc -l
@tamaki-shingo
tamaki-shingo / archive.sh
Last active August 29, 2015 14:13
clean -> build -> archive -> deploy to deploygate
xcodebuild -project hoge.xcodeproj clean DSTROOT="${HOME}/Desktop" SYMROOT="${HOME}/Desktop"
xcodebuild -project hoge.xcodeproj -configuration Release -target "hoge" install DSTROOT="${HOME}/Desktop" SYMROOT="${HOME}/Desktop"
xcrun -sdk iphoneos PackageApplication "${HOME}/Desktop/Applications/hoge.app" -o "${HOME}/Desktop/Applications/hoge.ipa" -embed "${HOME}/Library/MobileDevice/Provisioning Profiles/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mobileprovision"
dgate push -m "comment" "${HOME}/Desktop/Applications/hoge.ipa"
@tamaki-shingo
tamaki-shingo / showCodesigning.sh
Created January 15, 2015 08:27
show codesigning
/usr/bin/security find-identity -p codesigning -v