投稿

クラッシュ時のスタックトレース取得方法

iOS開発において、クラッシュした場所の検討がつかない場合がありました。 いろいろ調べてみると、NSSetUncaughtExceptionHandlerにハンドラ関数のポインタを渡すと、クラッシュ時のスタックトレースが取得できるようです。 以下のコードはその実装例。 @implementation AppDelegate void exceptionHandler(NSException *exception) { NSLog(@"Exception: %@", exception); NSLog(@"Stack Trace: %@", [exception callStackSymbols]); } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSSetUncaughtExceptionHandler(&exceptionHandler); return YES; } @end 以下のコードで無理やりExceptionを発生してみました。 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSSetUncaughtExceptionHandler(&exceptionHandler); //無理やりEcxeptionを発生させる。 NSArray *array = [NSArray array]; [array objectAtIndex:1]; return YES; } 出力結果は以下。 2013-07-15 19:21:45.415 ExceptionSample[27437:c07] Exception: *** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds for empty array ...

UITableViewCell の アニメーション

イメージ
どうやら、UITableViewCellを追加、削除、refreshするときのアニメーションがデフォルトで用意されている模様。 指定出来るアニメーションは以下の通り。 typedef NS_ENUM(NSInteger, UITableViewRowAnimation) { UITableViewRowAnimationFade, UITableViewRowAnimationRight, UITableViewRowAnimationLeft, UITableViewRowAnimationTop, UITableViewRowAnimationBottom, UITableViewRowAnimationNone, UITableViewRowAnimationMiddle, UITableViewRowAnimationAutomatic = 100 }; (例) リロードする場合は、UITableViewControllerのサブクラス内で、 - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; を以下の様に使用すればOK。 [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic]; 復習も兼ねて、全てのAnimationを確認するためのサンプルコードを作成した。 サンプルコード https://github.com/AlginPlus/TableCellAnimationSample

UITableViewCellの背景色を変更する

UITableViewの背景色を変更しようと以下のDataSourceでcellの背景色を変更しても上手くいかなかった。 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; cell.backgroundColor = [UIColor hogeColor]; return cell; } 背景色を変更するためには以下のDelegate内で指定すると上手くいくらしい… - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor hogeColor]; } とりあえず、よく間違えるのでメモ…

iPhoneのホームボタンがきかない時の対処法

イメージ
iPhone4を購入して1年半。 Homeボタンがほとんど反応しなくなった。 ネットで調べた対処法を試みたけど、一向に良くならない。 何か他にないかと、設定をいじっていたら、『Assistive Touch』という項目を発見した。 これをオンにするとスクリーン上からホームボタンを押せるようになった。 以下は、その設定方法です。 1)まず、ホーム画面の『設定』を押下 2)『一般』を押下 3)『アクセシビリティ』を押下 4)『AssisitiveTouch』を押下 4)『AssisitiveTouch』をオンにする 5)右下に『何か』が表示される。これを押下してみる 5)以下のように『ホーム』ボタンが表示される。

mac で LINE

イメージ
ついにMacでLINEが使えるようになったようですね。  iPhone版のLINEだと、メールアドレスの登録が出来ず、MacでLINEが使えない状態でしたが、 今回のバージョンアップ(2.0.0)でiPhoneでもアドレス登録ができるようになったようです。 1)iPhone 『設定』 −> アドレス登録 2)Macで設定 で使えるみたいです。 でも、実際使ってみると、Skypeでいいんじゃね?って思ったりもしますw

Mac Book Air で CUDA

イメージ
2年前に買ったAirですが、NVDIAのGPUだったことに今更気付いたw  せっかくなのでCUDAで遊んでみる。 今回はCUDA 4.1を使ってみます。 以下のサイトからDeveloper DriversとGPU Computing SDKとCUDA Toolkitをダウンロードします。 http://developer.nvidia.com/cuda-toolkit-41 ダウンロードが完了したら以下の順番でインストール。 (1) Developer Drivers (2) CUDA Toolkit (3) GPU Computing SDK 【以下のパスを通す】 PATH=/usr/local/cuda/bin:$PATH DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH 【CUDAのlibの権限変更】 $ sudo chmod 755 /usr/local/cuda/lib 【コンパイル】 ディレクトリ移動 $ cd /Developer/GPU Computing/C makeを実行し、ビルド $make 【サンプル起動】 ビルドが完了したらサンプルのあるフォルダに移動 $ cd /Developer/GPU Computing/C/bin/darwin/release/ ためしにマーチングキューブのサンプルを動かしてみる。 $./marchingCubes

Tweetビューア(作成中)

iPadでTweetViewerを作成しようと思う。 TwitterのAPIには、『BASIC認証』と『OAuth』の2通りの方法が用意されているよう… そんなこんなで、TweetDevに登録してみた。 登録内容はこんな感じ? ApplicationName:アプリケーションの名前 Description:アプリの説明書 Application Website:説明ページのURL Application Type:Client Default Access type: Read & Write  登録が完了すると登録内容が表示されるので、『Consumer key』、『Consumer secret』メモ。 これらをiPadからのアクセス時に使用する。  ※完了でき次第更新します。