wiedii's memo

色々メモリます。

MavericksでHomebrew使ってGaucheインストールした

Gaucheは手動でインストールしたけど、せっかくなのでHomebrewでGauche入れ直しました。

プログラミングGauche

まずGaucheをアンインストールします。
Gaucheソースコードがあるディレクトリに移動して…

$ make uninstall
cd src; /Applications/Xcode.app/Contents/Developer/usr/bin/make uninstall
for f in gosh gauche-config gauche-install gauche-package gauche-cesconv; do rm -f /usr/local/bin/$f; done
for f in libgauche-0.9.dylib; do rm -f /usr/local/lib/$f; done
rm -rf /usr/local/lib/gauche-0.9/0.9.3.3 /usr/local/share/gauche-0.9/0.9.3.3 /usr/local/lib/gauche-0.9/site/0.9.3.3
cd ext; /Applications/Xcode.app/Contents/Developer/usr/bin/make uninstall
for d in gauche util srfi threads uvector charconv binary net termios fcntl file sxml syslog dbm mt-random bcrypt digest vport text zlib sparse peg windows tls; do (cd $d; /Applications/Xcode.app/Contents/Developer/usr/bin/make uninstall); done
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
make[2]: Nothing to be done for `uninstall'.
for f in template.Makefile.in template.configure.ac template.extension.h template.extension.c template.extensionlib.stub template.module.scm template.test.scm template.DIST; do \
	  rm -f /usr/local/share/gauche-0.9/0.9.3.3/$f; \
	done
cd lib; /Applications/Xcode.app/Contents/Developer/usr/bin/make uninstall
make[1]: Nothing to be done for `uninstall'.
rm -f /usr/local/share/gauche-0.9/0.9.3.3//aclocal.m4
rm -f /usr/local/share/aclocal/gauche.m4

その後Homebrewのお決まりのコマンドを打っておきます。

$ brew doctor
Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours, this is a long time in brewland!
To update Homebrew, run `brew update`.
$ brew update
Updated Homebrew from f6ec5528 to 2c82712c.
==> New Formulae
cppi	  jvmtop    libestr
==> Updated Formulae
afflib		    gfortran		libp11		    riak
android-sdk	    graphicsmagick	libvirt		    rsyslog
autoconf-archive    imagemagick		mariadb		    ruby-build
automake	    isync		mpdscribble	    sane-backends
botan		    jsawk		mutt		    sysbench
cadaver		    ledger		ncdc		    uwsgi
elasticsearch	    libextractor	plowshare	    v8
elixir		    libgphoto2		postgres-xc	    valgrind
ffmpeg		    libmpd		qrencode	    wine
==> Deleted Formulae
gtkglextmm

というわけでGaucheをインストールする準備が出来ました。多分。

インストールする前に下調べをした結果

$ brew install --use-llvm gauche

のようなオプションを付けなければいけないと書いてあったので、その通りやっていましたが下記のようなエラーが。

$ brew install --use-llvm gauche
==> Downloading http://downloads.sourceforge.net/gauche/Gauche/Gauche-0.9.3.3.tg
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gauche/0.9.3.3 --enable-multibyte=utf
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/private/tmp/gauche-hKQU/Gauche-0.9.3.3/gc':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
configure: error: ./configure failed for gc

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

結局、

$ brew install gauche
==> Downloading http://downloads.sourceforge.net/gauche/Gauche/Gauche-0.9.3.3.tg
Already downloaded: /Library/Caches/Homebrew/gauche-0.9.3.3.tgz
==> ./configure --prefix=/usr/local/Cellar/gauche/0.9.3.3 --enable-multibyte=utf
==> make
==> make check
==> make install
Warning: Could not link gauche. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link gauche'

Possible conflicting files are:
/usr/local/share/man/man1/gosh.1
/usr/local/share/man/man1/gauche-package.1
/usr/local/share/man/man1/gauche-install.1
/usr/local/share/man/man1/gauche-config.1
/usr/local/share/man/man1/gauche-cesconv.1
==> Summary
🍺  /usr/local/Cellar/gauche/0.9.3.3: 316 files, 11M, built in 3.4 minutes
wiedii-no-MacBook-Pro:Gauche-0.9.3.3 wiedii$ brew update
Updated Homebrew from 2c82712c to 6ab3c1e8.
==> Updated Formulae
dub	  lilypond

で通りました:)
Mavericksとそれ以前(Lion, Mountain Lion等)では何か違うんですかね:)

で、またドクターを呼びました。

$ brew doctor
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:

    gauche
$ gosh
-bash: gosh: command not found

リンクが切れてるみたいなこと言われてますね。

$ brew link
This command requires a keg argument
$ brew link gauche
Linking /usr/local/Cellar/gauche/0.9.3.3... Warning: Could not link gauche. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/gauche/0.9.3.3/share/man/man1/gosh.1
Target /usr/local/share/man/man1/gosh.1 already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name
$

"man pageがあるぜ"みたいなこと言われてますね。
その後にコマンドが2つ示されてますが、自分の英語力じゃ理解不能でした。
こういう時は直感で行くしかないですね。

$ brew link --overwrite gauche
Linking /usr/local/Cellar/gauche/0.9.3.3... 14 symlinks created
$ gosh
gosh> (+ 1 2)
3
gosh> (exit)
$

動きましたね(なぜか)。

Land of Lisp

ちなみに

$ brew install gauche

というコマンドを実行する前に、

$ brew install --universal gdbm

というコマンドを実行していました。
gdbm, gaucheをアンインストールして再度、

$ brew install gauche

と実行しても、正常に動きました。

Dr. Homebrew

OS X Mavericksで外付けHDDデータ消失の恐れ -INTERNET Watch
ちなみにMavericksにしてからというもの、しょっちゅうクラッシュしてます。
Mavericksの場合、クラッシュしても黒い幕が上から降りてくるのでなく、白い画面に遷移した後強制的に再起動されるんですね:)

iTunesとiPhoneを同期した際に、ミュージックアプリのアーティスト欄にアーティストが表示されない。

"コンピレーションの一部"だと表示されないんですね。
アーティストに表示されません。: Apple サポートコミュニティ

iPhone 5s/5c 完全活用術 docomo版

iPhone 5s/5c 完全活用術 docomo版

f:id:wiedii:20131105233347p:plain

f:id:wiedii:20131105233352p:plain

iPhone 5s/5c Perfect Manual docomo対応版

CocoaPodsでld: library not found for -lPods clang: error: linker command failed with exit code 1 (use -v to see invocation)のようなエラーが出て困った。

「.xcodeproj」ではなく「.xcworkspace」を使います。

たのしいCocoaプログラミング[Leopard対応版]

たのしいCocoaプログラミング[Leopard対応版]

CocoaPods便利ですね。
CocoaPods: The Objective-C Library Manager

iOS(とMacOSX)で使うフレームワークを管理してくれるシステムです。
「かっこいいくるくる回るローディング画面作りたいな…SVProgressHUDってのがあるのか…ダウンロード…解凍…プロジェクトにドラッグアンドドロップ…」
「JSON処理しなきゃ…JSONKitが便利そうだ…ダウンロード…解凍…ドラッグアンド…」
CocoaPodsを使えばそういう部分を綺麗に管理できるようになります。

インストール

$ [sudo] gem install cocoapods
$ pod setup

今回は試しにSVProgressHUDをCocoaPodsを使って管理してみます。
SVProgressHUDは本当に便利です。
[SVProgressHUD show]
[SVProgressHUD dismiss]
この2つだけで簡単にインジケーター(であってるかな)が使えちゃいます。

CocoaPodsSampleというプロジェクトを、Empty Applicationテンプレートを使って作ります。
そんでもってTitleViewControllerというUIViewControllerのサブクラスを追加して、ひとまずXcodeを閉じます。

そしてTerminal.appを開いてプロジェクトファイルがあるディレクトリに移動します(CocoaPodsSample.xcodeprojがあるディレクトリ)。

$ cd (CocoaPodsSample.xcodeprojがあるディレクトリ)

そのディレクトリにPodfileというファイルを追加します。今回はemacsを使って作成します。

$ emacs Podfile

下記のような内容を入力して、Ctrl+x, Ctrl+s, Ctrl+x, Ctrl+cと入力します(Ctrl+はコントロールを押しながら)。

platform:ios
pod 'SVProgressHUD', '~>0.9'

そしてTerminalに戻ったら以下のコマンドでインストールを開始します。

$ pod install
pod install
Analyzing dependencies
Downloading dependencies
Installing SVProgressHUD (0.9)
Generating Pods project
Integrating client project
$

このあと何ですが、
「さてCocoaPodsSample.xcodeprojを開いて作業を続行するか…」は間違いでした。
新しいViewController作って、SVProgressHUD.hをimportしていざビルドしようとすると、
「ld: library not found for -lPods clang: error: linker command failed with exit code 1 (use -v to see invocation)」
のようなエラーが出ます。

ちょっと困りましたが、調べてみたら

$ pod install

というコマンドを打つと、自動で「(プロジェクト名).xcworkspace」というファイルが作られ、そのファイルを開いて作業をするようです:)

AppDelegate.m

#import "AppDelegate.h"
#import "TitleViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    TitleViewController *title = [[TitleViewController alloc] init];
    self.window.rootViewController = title;
    
    [self.window makeKeyAndVisible];
    return YES;
}
@end

TitleViewController.m

#import "TitleViewController.h"

@interface TitleViewController ()

@end

@implementation TitleViewController

-(id)init{
    if(self = [super init]){
        CGRect btn_rect = CGRectMake(0, 0, 100, 50);
        UIButton *hud_show = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [hud_show setBounds:btn_rect];
        [hud_show setTitle:@"HUD SHOW" forState:UIControlStateNormal];
        [hud_show setCenter:CGPointMake(100, 100)];
        
        UIButton *hud_dismiss = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [hud_dismiss setBounds:btn_rect];
        [hud_dismiss setTitle:@"HUD DISMISS" forState:UIControlStateNormal];
        [hud_dismiss setCenter:CGPointMake(200, 200)];
        
        [hud_show addTarget:self action:@selector(hudShow) forControlEvents:UIControlEventTouchUpInside];
        [hud_dismiss addTarget:self action:@selector(hudDismiss) forControlEvents:UIControlEventTouchUpInside];
        
        [self.view addSubview:hud_show];
        [self.view addSubview:hud_dismiss];
    }
    return self;
}

-(void)hudShow{
    [SVProgressHUD show];
}
-(void)hudDismiss{
    [SVProgressHUD dismiss];
}
@end

f:id:wiedii:20131102031816p:plain
:)

フレームワークの検索

$ pod search GPU


-> GPUImage (0.1.1)
   An open source iOS framework for GPU-based image and video processing.
   pod 'GPUImage', '~> 0.1.1'
   - Homepage: https://github.com/BradLarson/GPUImage
   - Source:   https://github.com/BradLarson/GPUImage.git
   - Versions: 0.1.1, 0.1.0, 0.0.1 [master repo]


-> GPUImage@siuying (0.0.2)
   Versioned fork of GPUImage.
   pod 'GPUImage@siuying', '~> 0.0.2'
   - Homepage: https://github.com/BradLarson/GPUImage
   - Source:   https://github.com/siuying/GPUImage.git
   - Versions: 0.0.2, 0.0.1 [master repo]


-> RDGPUImage (0.1.1)
   Versioned fork of GPUImage
   pod 'RDGPUImage', '~> 0.1.1'
   - Homepage: https://github.com/BradLarson/GPUImage
   - Source:   https://github.com/reigndesign/GPUImage.git
   - Versions: 0.1.1, 0.1.0 [master repo]


-> ZGPullDragScrollView (0.0.3)
   Awesome Scroll Category for DragUp and PullDown.
   pod 'ZGPullDragScrollView', '~> 0.0.3'
   - Homepage: https://github.com/zhigang1992/ZGPullDragScrollView
   - Source:   https://github.com/zhigang1992/ZGPullDragScrollView.git
   - Versions: 0.0.3, 0.0.2, 0.0.1 [master repo]


-> ZGPullDragTableView (0.0.1)
   Awesome TableView Category for Drag and Pull.
   pod 'ZGPullDragTableView', '~> 0.0.1'
   - Homepage: https://github.com/zhigang1992/ZGPullDragTableView
   - Source:   https://github.com/zhigang1992/ZGPullDragTableView.git
   - Versions: 0.0.1 [master repo]
$

CocoaPodsで追加したライブラリの削除方法は、Podfileで削除したいライブラリの記述を削除して、

$pod install

で出来ます。

森永 ミルクココア 300g

森永 ミルクココア 300g

ハートキャッチプリキュア! ココロポット

ハートキャッチプリキュア! ココロポット

Xcode5でデフォルトで生成されるStoryBoardって、デフォルトで消せないの?

Single View Applicationを作成するときに、「Use StoryBoard」のようなチェックボックスがあるのかと思ったら、見当たらないですね:(
なので勝手にStoryBoardが作られてしまいます:(
今のところ消し方分かりません:(

代替え案として
1.Empty Applicationを作成する。
2.Single View Applicationを作成した後StoryBoardを削除し、適当なViewControllerを表示させる。
を採用しています。

詳細! Objective-C iPhoneアプリ開発 入門ノート Xcode5+iOS 7対応

詳細! Objective-C iPhoneアプリ開発 入門ノート Xcode5+iOS 7対応

1.Empty Applicationを作成する。
これはそのままですね。
プロジェクト生成後はUIViewControllerのサブクラスを適当に作成して、AppDelegate.m内でインスタンスを生成してあげてそれを表示するという流れになると思います。

2.Single View Applicationを作成した後StoryBoardを削除する。
ここではとりあえず"SingleViewTest"というプロジェクト名を使っています。
プロジェクトを新規作成しSingle View Applicationのテンプレートを選択したら、多分以下の様なファイル構成になっていると思います。
f:id:wiedii:20131031190250p:plain
"Main.storyboard"を削除します(いつもMove to Trashにしてます)。
Supporting Filesディレクトリ内にSingleViewTest-Info.plistがあるので、"Main storyboard file base name"という項目を削除します(丸いマイナスボタンをクリック)。
ここでひとまずビルドしてみます。
多分成功します。
多分…。

あとは以下のようにソースコードを修正してやれば…
AppDelegate.m

#import "AppDelegate.h"
#import "ViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    self.window.rootViewController = [[ViewController alloc] init];
    [self.window makeKeyAndVisible];
    
    return YES;
}
@end

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

-(id)init{
    if(self = [super init]){
        self.view.backgroundColor = [UIColor orangeColor];
        CGRect button_rect = CGRectMake(0, 0, 100, 50);
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [button setBounds:button_rect];
        [button setTitle:@"alert" forState:UIControlStateNormal];
        [button addTarget:self action:@selector(showAlert) forControlEvents:UIControlEventTouchUpInside];
        [button setCenter:CGPointMake(self.view.center.x, 100)];
        [self.view addSubview:button];
    }
    return self;
}

-(void)showAlert{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"OBJC"
                                                    message:@"Hello, World!"
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
}
@end


f:id:wiedii:20131031185717p:plain
できましたね:)



詳解 Objective-C 2.0 第3版

詳解 Objective-C 2.0 第3版

Mavericks (Mac OSX 10.9)でWeb共有を使う

f:id:wiedii:20131031120327p:plain

LionからMavericksにしました。
Web共有がありませんね。
こういう時はTerminalからApacheを起動させます。

起動

$ sudo apachectl start

停止

$ sudo apachectl stop

再起動

$ sudo apachectl restart

という訳で起動して、ブラウザを立ち上げます。
アドレスバーに"localhost"と打ち込んでEnterを押すと…
f:id:wiedii:20131031121346p:plain

表示されましたね:)
ちなみにルートディレクトリは"/Library/WebServer/Documents"ぽいです:)
試しに何か放り込んでみます。
alert.html

<script>alert("hi");</script>

ルートディレクトリに上記のhtmlファイルを作成し、ブラウザのアドレスバーに"localhost/alert.html"と打ち込んでEnterを押すと…
f:id:wiedii:20131031122641p:plain

表示されましたね:)

Apacheクックブック 第2版 ―Webサーバ管理者のためのレシピ集

Apacheクックブック 第2版 ―Webサーバ管理者のためのレシピ集

PythonでPIL (Python Imaging Library)を使う

いつかのにゃんこ
f:id:wiedii:20131030234243j:plain


Pythonで画像処理をする時はPIL (Python Imaging Library)を使うらしいです。

実践 コンピュータビジョン

実践 コンピュータビジョン


でもいざ使おうとするとこんな感じのエラーが出ます。
test

from PIL import Image

im = Image.open("cat.jpg")
im.convert('L').show()

python test

$ python test
Traceback (most recent call last):
  File "test", line 4, in <module>
    im.convert("L").show()
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 679, in convert
    self.load()
  File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 189, in load
    d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 385, in _getdecoder
    raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available

どうやらlibjpegがないとダメっぽいです。
エラーメッセージ見て「なるほど...libjpegが足りないのか...」と判断した風に書きましたが、ググりました。
まずHomebrewでlibjpegをインストールします。
その後distributeというパッケージをインストールし、easy_installというコマンドでpipをインストールします。

distribute_setup.pyをダウンロードして実行します。
Index of /

$ sudo python distrubute_setup.py

pipをインストールします。

$ easy_install pip

PILをインストールする前に、Homebrewでlibjpegをインストールします。

$ brew install libjpeg

PILをインストールします。

$ pip install PIL

終わったらこんな感じの画面が出てくると思います。

    --------------------------------------------------------------------
    PIL 1.1.7 SETUP SUMMARY
    --------------------------------------------------------------------
    version       1.1.7
    platform      darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
                  [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
    --------------------------------------------------------------------
    --- TKINTER support available
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    *** FREETYPE2 support not available
    *** LITTLECMS support not available
    --------------------------------------------------------------------
    To add a missing option, make sure you have the required
    library, and set the corresponding ROOT variable in the
    setup.py script.
    
    To check the build, run the selftest.py script.
    changing mode of build/scripts-2.7/pilconvert.py from 644 to 755
    changing mode of build/scripts-2.7/pildriver.py from 644 to 755
    changing mode of build/scripts-2.7/pilfile.py from 644 to 755
    changing mode of build/scripts-2.7/pilfont.py from 644 to 755
    changing mode of build/scripts-2.7/pilprint.py from 644 to 755
    
    changing mode of /usr/local/bin/pilconvert.py to 755
    changing mode of /usr/local/bin/pildriver.py to 755
    changing mode of /usr/local/bin/pilfile.py to 755
    changing mode of /usr/local/bin/pilfont.py to 755
    changing mode of /usr/local/bin/pilprint.py to 755
Successfully installed PIL
Cleaning up...

JPEG support availableって書いてありますね。
libjpegを入れる前にPILを入れてしまったときは、PILをアンインストールして再度インストールするといいとかなんとか。

では再度実行...

from PIL import Image

im = Image.open("cat.jpg")
im.convert('L').show()

f:id:wiedii:20131031000030j:plain
neko ha kawaii desu ne!



memo

Homebrew:Mac用パッケージ管理システム
distribute:Python用パッケージ管理システム(?)
easy_install:distributeをインストールすることによって使えるようになるコマンド
pip:pythonのパッケージ管理システム
distrubute->pip setuptools->easy_install
???

初めてのPython 第3版

初めてのPython 第3版

UIImagePickerControllerで写真を撮る

iPhoneで写真を取るときはUIImagePickerViewControllerを使用する。


new->project->SingleView Applicationで、

ViewController.h

#import <UIKit/UIKit.h>
#import <MobileCoreServices/MobileCoreServices.h>

@interface ViewController : UIViewController<UIImagePickerControllerDelegate,UINavigationBarDelegate>
-(IBAction)ibShowCameraView:(id)sender;
-(IBAction)ibShowPhotosAlbum:(id)sender;
@end


ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
   
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)ibShowCameraView:(id)sender{
    BOOL cam = [self startCameraControllerFromViewController:self usingDelegate:self];
    if(cam)
        NSLog(@"camera");
    else
        NSLog(@"not camera");
}

-(BOOL)startCameraControllerFromViewController: (UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate, UINavigationBarDelegate>) delegate{
    if(([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) || delegate == nil || controller == nil){
        return NO;
    }
   
    UIImagePickerController* cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
    cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
    cameraUI.allowsEditing = NO;
    cameraUI.delegate = delegate;
    [controller presentModalViewController:cameraUI animated:YES];
    return YES;
}


// uiimagepicker delegates
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    NSLog(@"picker cancel");
    [self dismissModalViewControllerAnimated:YES];
    /*
    [[picker presentedViewController] dismissModalViewControllerAnimated:YES];
    [picker release];
     */
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    UIImage *originalImage, *editedImage, *imageToSave;
   
    // 静止画像のキャプチャを処理する
    if(CFStringCompare((CFStringRef)mediaType, kUTTypeImage, 0) == kCFCompareEqualTo){
        editedImage = (UIImage*)[info objectForKey:UIImagePickerControllerEditedImage];
        originalImage = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];
        if(editedImage)
            imageToSave = editedImage;
        else
            imageToSave = originalImage;
       
        //オリジナルまたは加工済みの新規画像をカメラロールに保存する
        UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil);
        NSLog(@"camera save");
    }
   
   
    //ムービーを保存
    if(CFStringCompare((CFStringRef)mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo){
        NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
       
        if(UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath)){
            UISaveVideoAtPathToSavedPhotosAlbum(moviePath, nil, nil, nil);
            NSLog(@"movie save");
        }
    }
    [self dismissModalViewControllerAnimated:YES];
    /*
    [[picker presentedViewController] dismissModalViewControllerAnimated:YES];
    [picker release];
     */
}

@end


ViewController.xib

UIButtonなんかを追加して、File's OwnerのShow the Connections InspectorでReceived ActionsのibShowCameraViewとUIButtonを接続。Touch Up Insideを選択。

ちなみにiOSプログラミングトピックスに載ってるコードをそのまま流用すると、Received memory warningとか出ます。なんででしょ。
iOSプログラミングトピックス

iPhoneプログラミングUIKit詳解リファレンス

iPhoneプログラミングUIKit詳解リファレンス