NSImage:isValid
Home 目次>ApplicationKit>NSImage

isValid

画像の内容があるかを返します


-(BOOL) isValid


【返り値】
   BOOLYES/NO


【解説】

画像の内容があるかを返します。



【例文】


#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender
{
//開けるファイル拡張子の配列
NSArray *imgTypes = [ NSArray arrayWithObject : @"tiff" ];
//OpenPanelを作る
NSOpenPanel *opImage = [ NSOpenPanel openPanel ];

//OpenPanelの結果のボタン番号
int opRet;
NSImageRep *imgRep;
NSImage *img=[[NSImage allocWithZone:[self zone]] initWithSize:NSMakeSize(100,100)];
//OpenPanelでファイル選択
opRet = [ opImage runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか
file : @"Pictures" //どのどのファイルを選択しておくか
types : imgTypes ];//選べるファイルタイプ

if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら
imgRep = [NSImageRep imageRepWithContentsOfFile:[ opImage filename ]];


[img addRepresentation:imgRep];

if ([img isValid]){
NSLog(@"YES");
}else{
NSLog(@"NO");
}

[image setImage:img];

}
}

@end


(C) 2000-2007 Satoshi Oomori.
[Apple]

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

この記事を評価してください。 

良い 

間違いがある 説明がわかりにくい 例文がわかりにくい  

Home 目次>ApplicationKit>NSImage
修正日2006.12.26