アプリ版:「スタンプのみでお礼する」機能のリリースについて

はじめまして。

iPhoneのアプリ作成に挑戦しています。

Xcode4のバージョンは 4.5.1です。

【はじめてのXcode4プログラミング】という参考書でIPhoneのカメラアプリを作る章があり、写真ライブラリから選択した画像を表示できるとのことです。

しかし、XcodeでRun(実行)すると、ViewController.mの最後から4行目【UIImage *originalImage = [info objectForkey:UIImagePickerControllerOriginalImage];】が赤くなり、【No visible @interface for 'NSDictionary' declares the selector 'objectForkey'】というエラー表示がでます。

全体のコードは下記の通りです。

ネットで調べてみましたが、解決方法がわかりません。

先に進めず困っています。

どうか解決方法を教えてください。

よろしくお願い致します。



●ViewController.h//

// ViewController.h
// CameraApp
//

#import

@interface ViewController : UIViewController
- (IBAction)pressCameraButton:(id)sender;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end



●ViewController.m

//
// ViewController.m
// CameraApp
//

#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.
}

- (IBAction)pressCameraButton:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[[self presentViewController:picker animated:YES completion:nil];}

- (void)imagePickerController:(UIImagePickerController*)Picker
didFinishPickingMediaWithInfo:(NSDictionary*)info
{
[self dismissViewControllerAnimated:YES completion:nil];
UIImage *originalImage = [info objectForkey:UIImagePickerControllerOriginalImage];

// ↑↑ 上記の行でエラーが出ます

self.imageView.image = originalImage;

}
@end

A 回答 (1件)

ぱっと見つけたのは、



objectForkey → objectForKey

ですね。
Objective-Cは大文字小文字まで正確に書かないと「そんなメソッド定義されてないよ」と蹴られます。
とりあえずこれを修正してください。他のエラーが出たら補足ということで。
    • good
    • 0
この回答へのお礼

ご指摘の通りでした。

無事解決しました。

ありがとうございました。

お礼日時:2012/12/07 18:33

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!