[Info] 写真ライブラリから複数画像を選択できるライブラリ

2011年11月16日水曜日 | Published in | 0 コメント

このエントリーをはてなブックマークに追加


サンプルの実行例。こんな感じで複数選択できる。

選択結果はデリゲートで受け取れる。
@interface ELCImagePickerController : UINavigationController {

 id delegate;
}

@property (nonatomic, assign) id delegate;

-(void)selectedAssets:(NSArray*)_assets;
-(void)cancelImagePicker;

@end

@protocol ELCImagePickerControllerDelegate

- (void)elcImagePickerController:(ELCImagePickerController *)picker
     didFinishPickingMediaWithInfo:(NSArray *)info;
- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker;

アルバムの選択用のクラスも用意されている。

@interface ELCAlbumPickerController : UITableViewController {
 
 NSMutableArray *assetGroups;
 NSOperationQueue *queue;
 id parent;
    
    ALAssetsLibrary *library;
}

@property (nonatomic, assign) id parent;
@property (nonatomic, retain) NSMutableArray *assetGroups;

-(void)selectedAssets:(NSArray*)_assets;

@end

悪くない。

[Info] ノンブロッキング/非同期処理ライブラリ - libuv

2011年11月15日火曜日 | Published in | 0 コメント

このエントリーをはてなブックマークに追加

nodejs用に作られたもので WindowsのIOCP、Unix上の libenvをラップしている。Non-blocking TCP sockets や Asynchronous DNS など標準では用意されていない便利な APIが提供されている。

joyent/libuv - GitHub

以下、Features を転載
  • Non-blocking TCP sockets
  • Non-blocking named pipes
  • UDP
  • Timers
  • Child process spawning
  • Asynchronous DNS via c-ares or uv_getaddrinfo.
  • Asynchronous file system APIs uv_fs_*
  • High resolution time uv_hrtime
  • Current executable path look up uv_exepath
  • Thread pool scheduling uv_queue_work
  • ANSI escape code controlled TTY uv_tty_t
  • File system events Currently supports inotify, ReadDirectoryChangesW and kqueue. Event ports in the near future. uv_fs_event_t
  • IPC and socket sharing between processes uv_write2

ネタ元はここ。
iOS 対応のパッチを提供してくれたとのこと。いいね。


[Info] UIView の contentStrecth による変形記事の紹介

| Published in | 0 コメント

このエントリーをはてなブックマークに追加

contentStretch を使った画像変形の解説。図入りでわかりやすい


例えばこんな設定をすると
imageView.frame = CGRectMake(10.0, 10.0, imageSize.width*1.2, imageSize.height); 
円形がこのように変形する。



[Info] iOS5から導入された Core Image のチュートリアル

| Published in | 0 コメント

このエントリーをはてなブックマークに追加


フィルタの適用や、適用後の画像をフォトアルバムへ書きだす方法などが説明されている。


(ネタ元)Twitter / @natsun_happy: Beginning Core Image in iO ...


[Info] メールアドレスピッカーライブラリ

2011年11月14日月曜日 | Published in | 0 コメント

このエントリーをはてなブックマークに追加

アドレス帳からメールアドレスを取得する簡易ライブラリ。利用しなくてもソースコードが参考になる(かも)。



[Info] 特定のファイルをiCloudバックアップ対象外にする

| Published in | 0 コメント

このエントリーをはてなブックマークに追加

iOS 5.0.1 から指定したファイルを iCloud および iTunes バックアップから除外できるようになった。その方法の紹介と関連してデータの種類毎の格納場所、バックアップの扱いの説明など。



データカテゴリ


データの用途によって4つのカテゴリが挙げられている。

カテゴリ用途ディレクトリバック
アップ対象
Critical Dataユーザが作成するデータ
または
再作成ができないデータ
Documents
Cached Data再ダウンロード
または
再作成が可能なデータ
Library/Caches×
Temporary Data使用期間の短い一時的な
データで保存が不要なデータ
tmp×
Offline Dataオフライン時に
利用するデータ
Documents または
Library/Private Documents
かつ拡張属性付与


拡張属性 "do not backkup"


iOS5.0.1 よりファイルに 拡張属性 "do not backup" を付与することで特定のファイルを iCloud/iTunesバックアップの対象外にできる。以下は Technical Q&A からの転載。
#include <sys/xattr.h>
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    const char* filePath = [[URL path] fileSystemRepresentation];
 
    const char* attrName = "com.apple.MobileBackup";
    u_int8_t attrValue = 1;
 
    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
    return result == 0;
}
拡張属性が認識されるのは iOS5.0.1以降。それ以前は機能しない(つまりバックアップされる)。


参考情報


setxattr(2) Mac OS X Developer Tools Manual Page

setxattr関数のマニュアル

[Info] BlocksKit

| Published in | 0 コメント

このエントリーをはてなブックマークに追加

Foundation や UIKit ライブラリの様々なクラスのメソッドを blocks 化したライブラリ。 iOS 4.0+ 、 Mac OS X 10.6+ で利用可能。


以下、READMEより転載。

What's In The Box

  • Performing blocks on an NSObject.
  • Key-value observation () with block handlers.
  • Associated objects in an Obj-C API. (Not directly block-related.)
  • NSArray, NSSet, NSDictionary, and NSIndexSet filtering and enumeration.
  • Macros for more quickly typing out the above.
  • NSInvocation creation using a block.
  • NSTimer block execution.
  • Both delegation and block callbacks on NSURLConnection.
  • Delegate callback for NSCache.

UIKit Extensions
  • UIAlertView, UIActionSheet with block callbacks and convenience methods.
  • Block initializers for UIControl and UIBarButtonItem
  • Block-backed initializers for UIGestureRecognizer.
  • On-touch utilities for UIView.
  • Block callbacks for MFMailComposeViewController and MFMessageComposeViewController.
  • Delegate alternative for UIWebView.
これはいい。ちょっとした処理を書くのにいちいちメソッドを起こさなくて済む。本来は Appleが提供して欲しいものだが。
リファレンスマニュアルが appledoc形式で提供されている。
BlocksKit Reference

以下、リファレンスから少し抜粋してみる。

UIActionSheet(BlocksKit)
UIActionSheet *testSheet = [UIActionSheet sheetWithTitle:@"Please select one."];
 [testSheet addButtonWithTitle:@"Zip" handler:^{ NSLog(@"Zip!"); }];
 [testSheet addButtonWithTitle:@"Zap" handler:^{ NSLog(@"Zap!"); }];
 [testSheet addButtonWithTitle:@"Zop" handler:^{ NSLog(@"Zop!"); }];
 [testSheet setDestructiveButtonWithTitle:@"No!" handler:^{ NSLog(@"Fine!"); }];
 [testSheet setCancelButtonWithTitle:nil handler:^{ NSLog(@"Never mind, then!"); }];
 [testSheet showInView:self.view];

NSObject(BlocksKit)
[object performBlock:^(){
  [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
} afterDelay:0.5f];


UIGestureRecognizer もある。
UIGestureRecognizer(BlocksKit)
UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(id sender) {
     NSLog(@"Single tap.");
 } delay:0.18];
 [self addGestureRecognizer:singleTap];


- - - -
かなり便利なので、いったん使い始めたら以後このライブラリ無しではコーディングできなくなりそうで怖い。。

人気の投稿(過去 30日間)