dataWithContentsOfURL:
指定したURLからデータオブジェクトを作って返します
+(id)dataWithContentsOfURL:(NSURL *)anURL
解説
指定したURL(anURL)からデータオブジェクトを作って返します。
フレームワーク
Foundation
クラス
NSData
使用可能
10.0
参照
関連記事(外部サイト)
例文
#import "SetImage.h" @implementation SetImage - (IBAction)set:(id)sender { //Imageを作る NSImage *img = [[[NSImage alloc] initWithSize:NSMakeSize(100,100)] autorelease]; NSBitmapImageRep *bmpRep; NSData *dat; NSURL *url = [NSURL URLWithString:@"http://www.oomori.com/image/oomoricom.png"]; dat = [NSData dataWithContentsOfURL: url ]; bmpRep = [NSBitmapImageRep imageRepWithData:dat]; [img addRepresentation:bmpRep]; [image setImage:img]; NSLog([NSString stringWithFormat:@"bit / pixel:%d",[bmpRep bitsPerPixel]]); } @end