Shift-Command-O (Open Quickly)はファイル名だけでなくメソッド名や関数名ほか各種定義でも行けるらしい。
試しに open と入れると...
おおおおぉ。これは知らなかった。便利。
Published on 2013年12月11日水曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年10月2日水曜日 Leave your thoughts »
|
|
Tweet |
面白い。
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]]; [formatter setDateFormat:@"MMM d yyyy"]; [formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; NSString *string = @__DATE__; NSDate *buildDate = [formatter dateFromString:string]; [formatter release];
This post is archived under Tips
Published on 2013年10月1日火曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年9月26日木曜日 Leave your thoughts »
|
|
Tweet |
#define OBJC_STRINGIFY(x) @#x #define encodeObject(x) [aCoder encodeObject:x forKey:OBJC_STRINGIFY(x)] #define decodeObject(x) x = [aDecoder decodeObjectForKey:OBJC_STRINGIFY(x)]
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
if(self) {
_obj = [aDecoder decodeObjectForKey:@"_obj"];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeInt:_val forKey:@"_obj"];
}(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
if(self) {
decodeObject(_obj);
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
encodeObject(_obj);
}#define STRINGIFY(x) #x int myVariable = 5; NSLog(@"%s", STRINGIFY(myVariable));と書けば、"myVariable" がログに出る。
#define OBJC_STRINGIFY(x) @#x int myVariable = 5; NSString *foo = OBJC_STRINGIFY(myVariable); NSLog(@"%@", foo);も "myVariable" がログに出る。
This post is archived under Tips
Published on 2013年8月12日月曜日 Leave your thoughts »
|
|
Tweet |
面白いのは新旧ViewControllerのビューのスクリーンショットを取ってトランジションさせるところ。
//Create a UIImageView from the given layer
- (UIImageView*)takeScreenshot:(CALayer*)layer{
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, [[UIScreen mainScreen] scale]);
[layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIImageView *screnshot = [[UIImageView alloc] initWithImage:image];
return screnshot;
}This post is archived under Tips
Published on 2013年7月19日金曜日 Leave your thoughts »
|
|
Tweet |
NSArray *animals=@[
@{@"name" : @"Dog",
@"numberOfLegs" : @4,
@"breeds" : @[
@{@"name" : @"Lab", @"price" : @299.99},
@{@"name" : @"Collie", @"price" : @199.99},
@{@"name" : @"Shepard", @"price" : @299.99}
]
},
@{@"name" : @"Cat",
@"numberOfLegs" : @4,
@"breeds" : @[
@{@"name" : @"Siamese", @"price" : @99.99},
@{@"name" : @"Persian", @"price" : @89.99},
@{@"name" : @"Himalayan", @"price" : @79.99}
]
},
@{@"name" : @"Spider",
@"numberOfLegs" : @8,
@"breeds" : @[
:
id avgNumberOfLegs = [animals valueForKeyPath:@"@avg.numberOfLegs"];オペレータは @min, @max, @avg, @count, @sum などの集計系の他、@unionOfObjects などの集合系がある。
NSArray* names = [animals valueForKeyPath:@"@unionOfObjects.name"];なら
(
Dog,
Cat,
Spider,
Fish,
Goose
)となる。特定要素の列挙したい場面は多々あるのでこれは便利。This post is archived under Tips
Published on 2013年7月13日土曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年7月11日木曜日 Leave your thoughts »
|
|
Tweet |
一つ前のポストと似たような話題でブレークポイントのTIpsをもう一つ。
Stack-trace-dumping regular-expression-based symbolic breakpoints in LLDB
LLDBの --func-regex オプションを使うと正規表現でクラス名を指定できて、そのすべてのメソッドにブレークポイントを設定することができる。
(lldb) breakpoint set --func-regex NSLayoutManagerとすると NSLayoutManagerのそれぞれのメソッドでブレークポイントが働くようになる。
(lldb) breakpoint command add 2 Enter your debugger command(s). Type 'DONE' to end. > script print "----------" > bt > continue > DONE (lldb)最後に continueを入れているので出力後は止まらずに実行を継続する。
(lldb) breakpoint set --func-regex "\[NSLayoutManager"するとNSLayoutManagerLogDebug()などが除外される。
This post is archived under LLDB, Tips
Published on 2013年4月21日日曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年4月5日金曜日 Leave your thoughts »
|
|
Tweet |
基本的だが効果的なTipsが紹介されていている。
1. ARCを使う参考になった。長いが一読をお勧め。
2. reuseIdentifierを使う
3. 可能なかぎりOpaqueで(不透明で)
4. XIBを肥大化させない
5. メインスレッドをブロックしない
6. イメージはできるだけ表示サイズに合わせる
7. 適切なコレクションクラスを選ぶ
8. ネットワーク転送でGZIPを使う
9. ビューは再利用と遅延ロードする
10. キャッシュを使え
11. 必要ならCoreGraphicsで描く
12. メモリ警告が出たら不要なメモリを開放
13. 高コストなオブジェクトの再利用(NSDateFormatterの再利用)
14. スプライトシートを使う
15. 前の計算結果を使う
16. 適切なデータ型の選択
17. 背景画像は大きさに応じた方法で
18. UIWebViewは注意深く利用(重いJS Frameworkは避ける)
19. 影を付けるなら .shadowPathを使う
20. UITableViewを最適化する(いろいろなTips!)
21. 用途に応じた適切なストレージを選ぶ(いろいろなストレージ)
22. 非同期を活用して起動をスピードアップ、XIBは小さく
23. Autorelease Pool を使う
24. 画像キャッシュを意識する(imageNamed:の使用)
25. 日付は Unix timestampを使う(場合によっては)
This post is archived under Tips
Published on 2013年4月1日月曜日 Leave your thoughts »
|
|
Tweet |
今ちょうど四苦八苦しているところでもあり合点のいくことが多かった。
※リンク間違ってました..
1. Rule of Thumb: At Least Two Constraints in Each Dimension
2. Embrace Intrinsic Size
3. IB Will Never Let You Create Ambiguous Layouts
4. Before You Can Delete An Existing Constraint, You Must Create Another One
5. Don’t Resize Controls Explicitly
6. Avoid Premature Optimization
7. Forget frame
8. Don’t Forget To Disable Autoresizing Masks
9. The Debugger Console Is Your Friend
10. Animate the Constraints, Not the Frame
←−−−→|←−−−−−−−→| 左位置 幅の制約 の制約
←−−−→|←−−−−−−−→|←−−−→ 左位置 幅の制約 右位置 の制約 の制約この状態では左・右・幅共に固定。
←−−−→|←−−−−−−−→|←−−−→ 左位置 (可変) 右位置 の制約 の制約すると幅が可変になる。

7. Forget frameAutolayout以降はレイアウト調整だけでなくアニメーションの仕方もやり方が変わるということか。
10. Animate the Constraints, Not the Frame
This post is archived under Autolayout, Tips
Published on 2013年3月18日月曜日 Leave your thoughts »
|
|
Tweet |
OS X アプリの話だが iOSでも十分参考になる。具体的で役に立ついい記事。
1. できるだけ別スレッドで
- テキストサイズの計算
- Core Data のフェッチやインサート
- イメージのロードとサムネイルの生成
2. 必要になるまで作らない
3. 起動時の処理を少なく
4. 呼び出し回数を少なく
5. View を少なくする
6. 文字列検索は CFStringFind を使う
7. 定期的にチェック
This post is archived under Tips
Published on 2013年3月14日木曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年3月13日水曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年1月29日火曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年1月25日金曜日 Leave your thoughts »
|
|
Tweet |
Published on 2013年1月16日水曜日 Leave your thoughts »
|
|
Tweet |