이것이 올바른 방법일까요?dispatch_data_t를 NSData로 변환하는 방법은 무엇입니까?
// convert
const void *buffer = NULL;
size_t size = 0;
dispatch_data_t new_data_file = dispatch_data_create_map(data, &buffer, &size);
if(new_data_file){ /* to avoid warning really - since dispatch_data_create_map demands we care about the return arg */}
NSData *nsdata = [[NSData alloc] initWithBytes:buffer length:size];
// use the nsdata... code removed for general purpose
// clean up
[nsdata release];
free(buffer); // warning: passing const void * to parameter of type void *
잘 작동합니다. 나의 주요 관심사는 메모리 누출이다. 데이터 버퍼 누수는 재미 있지 않습니다. 그래서 NSData, 버퍼 및 dispatch_data_t new_data_file 모두 괜찮습니까?
내가 읽을 수있는 내용은 http://opensource.apple.com/source/libdispatch/libdispatch-187.7/dispatch/data.c이며 버퍼는 DISPATCH_DATA_DESTRUCTOR_FREE 인 것 같습니다. 버퍼를 비우는 것이 내 책임이라는 뜻입니까?
이것은 iOS 7/10.9에만 해당됩니다. –
Thx, 예, 출시 노트 링크를 추가했습니다. – catlan
다른 사람들을위한 해결책은 무엇입니까? –