Skip to content

Instantly share code, notes, and snippets.

@roothybrid7
roothybrid7 / file0.txt
Last active August 29, 2015 14:14
実行中のNSOperationに考慮しつつ、NSOperationQueueのキャンセルを実行する ref: http://qiita.com/roothybrid7/items/83db3809775295ea6df3
// DataParseOperationQueue.h
#import <Foundation/Foundation.h>
@interface DataParseOperationQueue : NSOperationQueue
// XXX: 全ての実行中の`NSOperation`が終わるまで待ち、完了したらcompletionHandler blocksを実行する
- (void)cancelAllOperationsWithCompletionHandler:(void(^)(void))completionHandler;
@end
@roothybrid7
roothybrid7 / file0.txt
Last active August 29, 2015 14:14
ソート済みのNSArrayに、順番を保ちつつ新しいデータを追加する ref: http://qiita.com/roothybrid7/items/15fd39af876a9b7caa90
NSArray *sourceData = @[
@{@"id": @"A", @"createdAt": @1234533333},
@{@"id": @"B", @"createdAt": @1234599999},
@{@"id": @"C", @"createdAt": @1234511111},
@{@"id": @"D", @"createdAt": @1234522222},
@{@"id": @"E", @"createdAt": @1234599999},
];
// Sort descritors
NSSortDescriptor *createdAtSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"createdAt" ascending:NO];
@roothybrid7
roothybrid7 / file0.txt
Created February 1, 2015 23:11
デバイスが32bitなのか64bitなのかチェックする ref: http://qiita.com/roothybrid7/items/3cfeb2837cb468bcab13
if (sizeof(int *) == 4) {
// 32bit
} else if (sizeof(int *) == 8) {
// 64bit
}
// others
@roothybrid7
roothybrid7 / file0.txt
Created October 13, 2014 07:11
Xcode 6でコマンドラインを使ってテストを実行する(`destination`パラメータの調査) ref: http://qiita.com/roothybrid7/items/19f0aeeee98573dab2a6
xcodebuild test -workspace App.xcworkspace -scheme AppLogicTests \
-destination 'platform=Android,name=spam'
#[...]
Available destinations for the "AppLogicTests" scheme:
{ platform:iOS Simulator, id:1BE387A6-5747-40E5-B0CD-D09BF2ACB111, OS:7.0.3, name:iPad 2 }
{ platform:iOS Simulator, id:45E116FB-48BB-495E-90D3-130EE83FE36E, OS:7.1, name:iPad 2 }
{ platform:iOS Simulator, id:99C7DD9A-5706-441B-86E2-CA0132DA02E0, OS:8.0, name:iPad 2 }
{ platform:iOS Simulator, id:A22100E1-928C-4EF0-AD4A-1F7DFEEAC57F, OS:7.0.3, name:iPad Air }
{ platform:iOS Simulator, id:89C643E9-3031-4276-BCF5-E29A51489A8E, OS:7.1, name:iPad Air }
{ platform:iOS Simulator, id:08020160-40A3-4601-802D-187972CE1A42, OS:8.0, name:iPad Air }
@roothybrid7
roothybrid7 / App-dev.xcconfig
Created August 10, 2014 02:31
CocoaPodsで、アプリ側のターゲットに複数のPodsターゲットをリンクするときの設定 ref: http://qiita.com/roothybrid7/items/522398b89aaf2591b8a9
#include "Pods/Pods.xcconfig"
#include "Pods/Pods-Experimental.xcconfig"
#include "Pods/Pods-Temporary.xcconfig"
@roothybrid7
roothybrid7 / coredata.txt
Created May 4, 2014 03:21
Core Data debugging arguments
# CoreData debugging.
-com.apple.CoreData.SQLDebug 3
-com.apple.CoreData.MigrationDebug
-com.apple.CoreData.SyntaxColoredLogging YES
@roothybrid7
roothybrid7 / XXXTestCase.h
Created April 9, 2014 02:21
iOSのユニットテスト(LogicTests)で和暦設定時のテストを行う ref: http://qiita.com/roothybrid7/items/7185073390e308d5862b
#import <SenTestingKit/SenTestingKit.h>
#import <OCMock/OCMock.h>
@interface XXXTestCase : SenTestCase
#pragma mark - NSLocale(ja_JP@calendar=japanese)
/*!
@method createJPLocaleWithJapaneseCalendarMock
@roothybrid7
roothybrid7 / Podfile
Created March 26, 2014 06:30
CocoaPodsでアプリ側ターゲットのbuild_settingsを変更する方法 ref: http://qiita.com/roothybrid7/items/403b2fb453b1674102a4
TESTING_TARGETS = %w[AppTests AppIntegrationTests]
post_install do |installer|
# アプリ側のxcode projectを開く
Xcodeproj::Project.open('App.xcodeproj').tap do |project|
targets = project.targets.find_all do |target|
TESTING_TARGETS.include?(target.name)
end
# Test用macro定義
targets.each do |target|
target.build_configurations.each do |config|
@roothybrid7
roothybrid7 / file0.txt
Created March 16, 2014 11:18
vagrant packageしないで、vagrantとVirtualBoxをアップデートしてしまってVMを起動できなくなったのを救う方法 ref: http://qiita.com/roothybrid7/items/6fa876ba3fcea9a005d1
VBoxManage export <VM name> -o export.ova
@roothybrid7
roothybrid7 / file0.txt
Created March 13, 2014 10:59
Xcodeを複数使用している場合に、Xcode Plug-inを両方で使う方法 ref: http://qiita.com/roothybrid7/items/5d99071936634100f0ac
cd ~/Library/Application Support/Developer/Shared
mkdir Xcode\ 5.0.2 # <= ダウンロードしたXcodeにつけた名前でディレクトリを作成
cp -r Xcode/Plug-ins Xcode\ 5.0.2/