NSData:dataWithContentsOfURL:
Home 目次>Foundation>NSData このサイトはこちらに移転しました。

dataWithContentsOfURL:

指定したURLからデータオブジェクトを作って返します


+(id) dataWithContentsOfURL:(NSURL *)anURL


【返り値】
   idデータ
【パラメータ】
   anURLURL


【解説】

指定したURL(anURL)からデータオブジェクトを作って返します。



【例文】


#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


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

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

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

良い 

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

Home 目次>Foundation>NSData
修正日2006.12.26