objc
// 正規表現オブジェクトを作成 NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:@"reg_exp" options:NSRegularExpressionCaseInsensitive error:nil]; NSString *targetString = @"target string" // 検索実…
ヘッダファイル extern const struct LocalNotificationAttributes { __unsafe_unretained NSString *weeklyWork; } LocalNotificationAttributes; mファイル const struct LocalNotificationAttributes LocalNotification = { .weeklyWork = @"LocalNotific…
以下のようなコードを書くと int val = 299; NSAssert((0 <= val) && (val <= 255), @"Value is out of range!"); こんな感じでログが出て強制終了する. 2013-11-20 16:49:12.779 AppDemo[1935:60b] *** Assertion failure in -[HomeViewController viewDidL…
ボタンがadd subviewされる側のクラスによって指定ができるけど, ちょっと使いづらい. カスタムなボタンを作った方がよいかもしれない. UIImage *btnImg = [UIImage imageNamed:@"hoge"]; UIImage *btnImgHighlighted = [UIImage imageNamed:@"fuga"]; [[UIB…
int r = arc4random_uniform(3); // range is 0~2 参考: http://programming-ios.com/objective_c-arc4random/
ナビゲーションバーとステータスバーを除いた画面の高さを取得する. float backButtonYorigin = [[UIScreen mainScreen] applicationFrame].size.height - self.navigationController.navigationBar.height; コントロールの位置指定を 下からの距離で指定す…
Deferredとは? 元ネタはjsからきた. 既存では非同期処理において完了,未完了の場合ごとにBlock実行をするというアイディアだったが そうはせずに, 完了,未完了の状態を持ったDefferedオブジェクトを即座に返すと言う方針. Defferedオブジェクトは完了もしく…
たまに補完で出てきてくれないときがあるのでメモ NSNumber *hoge; [hoge isEqual:[NSNull null]]
kは定数のプレフィックス. // .m file #import "ScrollButtonsView.h" static const int kButtonNumber = 5; static const float kButtonPadding = 10.0f; @implementation ScrollButtonsView /* 省略 */ @end 文字列定数の場合は以下の通り // .h file #imp…
実装ファイル #import "ViewController.h" #import "CustomView.h" typedef void(^testBlockType)(void); @interface ViewController () @property (nonatomic, copy) testBlockType success; @property (nonatomic, copy) testBlockType failuer; @end @imp…
iQONのView構成紹介 14ページ目 http://www.slideshare.net/ararajp/vasilyretty?ref=http://tech.vasily.jp/2013/09/ios_iqon_view/ のスパイクプロジェクトをつくってみた. カスタムビューを作ったときにカスタムビューのなかではなく それを使うビューコ…
typedef を使って Blockの型を独自に定義することができる. View.h #import <UIKit/UIKit.h> typedef void(^MyCustomBlockType)(void); @interface CustomView : UIView @property (nonatomic, copy) MyCustomBlockType blockName; @property (nonatomic, copy) void (^bloc</uikit/uikit.h>…
以下を pchファイルに書けばOKです. // Debug #ifdef DEBUG #define DLOG(format, ...) NSLog((@"%s: %d: " format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) #else #define DLOG(format, ...) #endif pod にしたい... たしか, pod install したとき…
typedef NS_ENUM(NSInteger, HogeState) { HogeStateStart, HogeStatePause, HogeStateEnd };
Objective-C の BOOL型はint型で以下のように定義されている. YES: 1 NO: 0 objc.h ヘッダファイルにもそのように定義されている. 忘れたら BOOLの定義を ctrl+gで見れば良い. objc.hでの定義内容を以下に示す. /// Type to represent a boolean value. type…
NSString* (^test)(NSString*, NSString*) = ^(NSString* head, NSString* tail){ return [NSString stringWithFormat:@"%@%@", head, tail]; }; NSLog(@"%@", test(@"hoge", @"fuga"));