는이 코드로 인터넷에서 .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 사용 방법. –
예 .. 우스, 맥 질문 이었나요? 나는 너무 오랫동안 프로그래밍 해왔다. :) – mjhoy
그것이 Mac이나 iPhone의 질문인지는 알 수 없다. –