| Home 目次>Foundation>NSData このサイトはこちらに移転しました。 | |
dataWithContentsOfURL:
指定したURLからデータオブジェクトを作って返します
+(id) dataWithContentsOfURL:(NSURL *)anURL
【返り値】 | |
| id | データ |
| 【パラメータ】 | |
| anURL | URL |
【解説】
指定した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
![]() | |
この記事を評価してください。
| Home 目次>Foundation>NSData | 修正日2006.12.26 |