2013年10月4日金曜日

read ios application source


design pattern

http://www.raywenderlich.com/46988/ios-design-patterns/

*NSKeyedUnarchiver can be used to save data.
-to save data:
NSMutableArray *albums;
albums = [NSMutableArray arrayWithArray:
@[[[Album alloc] initWithTitle:@"Best of Bowie" artist:@"David Bowie" coverUrl:@"http://www.coversproject.com/static/thumbs/album/album_david%20bowie_best%20of%20bowie.png" year:@"1992"],
[[Album alloc] initWithTitle:@"It's My Life" artist:@"No Doubt" coverUrl:@"http://www.coversproject.com/static/thumbs/album/album_no%20doubt_its%20my%20life%20%20bathwater.png" year:@"2003"],
[[Album alloc] initWithTitle:@"Nothing Like The Sun" artist:@"Sting" coverUrl:@"http://www.coversproject.com/static/thumbs/album/album_sting_nothing%20like%20the%20sun.png" year:@"1999"],
[[Album alloc] initWithTitle:@"Staring at the Sun" artist:@"U2" coverUrl:@"http://www.coversproject.com/static/thumbs/album/album_u2_staring%20at%20the%20sun.png" year:@"2000"],
[[Album alloc] initWithTitle:@"American Pie" artist:@"Madonna" coverUrl:@"http://www.coversproject.com/static/thumbs/album/album_madonna_american%20pie.png" year:@"2000"]]];

NSString *filename = [NSHomeDirectory() stringByAppendingString:@"/Documents/albums.bin"];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:albums];
[data writeToFile:filename atomically:YES];

-to read data:
NSData *data = [NSData dataWithContentsOfFile:[NSHomeDirectory() stringByAppendingString:@"/Documents/albums.bin"]];
albums = [NSKeyedUnarchiver unarchiveObjectWithData:data];


*when to set layout
note that the toolbar isn’t initiated with a frame, as the frame size set in viewDidLoad isn’t final. So set the final frame via the following block of code once the view frame is finalized by adding the code to
- (void)viewWillLayoutSubviews
{
    toolbar.frame = CGRectMake(0, self.view.frame.size.height-44, self.view.frame.size.width, 44);
    dataTable.frame = CGRectMake(0, 130, self.view.frame.size.width, self.view.frame.size.height - 200);
}

*how to remove all the subviews.
[scroller.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [obj removeFromSuperview];
}];

*to save user data before the application entered background.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveCurrentState) name:UIApplicationDidEnterBackgroundNotification object:nil];
- (void)saveCurrentState
{
    [[NSUserDefaults standardUserDefaults] setInteger:currentAlbumIndex forKey:@"currentAlbumIndex"];
    [[LibraryAPI sharedInstance] saveAlbums];
}
NOTE: need to call loadPreviousState from viewDidLoad()

*post notification
[[NSNotificationCenter defaultCenter] postNotificationName:@"BLDownloadImageNotification"
                                                        object:self
                                                      userInfo:@{@"imageView":coverImage, @"coverUrl":albumCover}];
*receive notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadImage:) name:@"BLDownloadImageNotification" object:nil];

2013年10月3日木曜日

HTC One Google Play edition の root 化

  • bootloaderをunlockする
    • adb reboot bootloader
    • 端末が再起動されるので、起動されたあと、下記コマンド
      • fastboot oem unlock
    • 参考サイト
      • https://source.android.com/source/building-devices.html
  • UPDATE-SuperSUをsdcardに保存する
    • DL先:http://forum.xda-developers.com/showthread.php?t=1538053
    • 下記コマンドでshared storageにcopy
      • adb push UPDATE-SuperSUXXXX.zip /mnt/sdcard/
  • recoveryモードでこのzipファイルを選択してinstall
    • この状態でadb reboot recoveryでリカバリモードに入れないので、まずは下記をインストール
      • ClockworkMod TouchをDL
        • DL先:http://forum.xda-developers.com/showthread.php?t=2173863
      • adb reboot bootloader
      • fastboot flash recovery recovery-clockwork-touch-xxx.img
    • adb reboot recoveryでリカバリモードに入る
    • install zip -> choose zip from sdcard で先ほどコピーしたzipファイルをinstall
元ネタ:http://mmasashi-js.blogspot.jp/2013/07/htc-one-google-play-edition-rooted-2.html

2013年8月16日金曜日

ios開発時のdebug方法

http://d.hatena.ne.jp/Psychs/20081120/1227203259

2013年6月18日火曜日

iOS データ保存

You might want to persist the score by saving it to the NSUserDefaults or a keychain. More on secure storage of data with a keychain.

2013年4月19日金曜日

gmailの文字化け対策

■対策
gmailの署名にユニコードの文字を入力する。

■手順
・Gmailの送信用文字コードをutf-8にする。
・Gmailの署名にノーブレークスペースを追加する。
 →追加の仕方:下記で[入力方法]で検索

以上

2013年2月12日火曜日

Launch controls on stopped applications

新しいアプリステートのstop状態が追加された。

使い方、確認の仕方
http://y-anz-m.blogspot.jp/2011/05/android-31-platform.html

詳細:
http://developer.android.com/about/versions/android-3.1.html