私はこのコードを、インターネットから.jpgファイルをダウンロード:NSMutableDataをビューのイメージに変換するにはどうすればよいですか?
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://cvcl.mit.edu/hybrid/cat2.jpg"]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
receivedData=[[NSMutableData data] retain]; // etc etc
すべてが正常に動作します。私はちょうどデータを扱う方法を知らない。 IBでイメージビューを作成したとします。イメージを表示するにはどうすればいいですか?ここでは最後のビットです:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// ******do something with the data*********...but how
NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
// release the connection, and the data object
[connection release];
[receivedData release];
}
Macでこれが必要な場合は、NSImageのinitWithData:メソッドを使用してください。 –
よろしくお願いします。それはMacの質問ですか?私はあまりにも長くプログラミングしています:) – mjhoy
それはMacかiPhoneの質問かどうかの兆候はありません。 –