| Home 目次>ApplicationKit>NSImage | |
isDataRetained
データを保持するかを返します
-(BOOL) isDataRetained
【返り値】 | |
| BOOL | 保持されるかYES/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];
[img setDataRetained: YES ];
if ([img isDataRetained]){
NSLog( @"YES" );
} else {
NSLog( @"NO" );
}
[image setImage:img];
}
}
@end
![]() | |
この記事を評価してください。
| Home 目次>ApplicationKit>NSImage | 修正日2006.12.26 |