그래서, 내가 NSArrays 많이 사용하기 때문에 내가 여기에 매크로를 기반으로, 전달 프리미티브에서 배열을 생성하는 매크로를 만들려고 시도하기로 결정 그래서 기본적으로 자동 권투 NSArray?
#define $array(values...) ({ void *v[] = { values }; const char *encodings[] = { /* how do I get the @encode-ings for each? */ }; _boxArray(v, encodings, sizeof(values)/sizeof(void *))})
NSValue *_box(void *value, const char *encoding); // defined by CollectionUtils
NSArray *_boxArray(void **values, const char **encodings, int count)
{
id objects[count];
for (int i = 0; i < count; i++) {
// how can I box all of the values that need boxing?
objects[i] = _box(values[i], encodings[i]);
}
return [NSArray arrayWithObjects:objects count:count];
}
https://bitbucket.org/snej/myutilities/src/319441e240fa/CollectionUtils.h
, 내가 무엇을 물어, 어떻게 variadic 매크로, 매크로에 전달 된 각 인수 작업을 수행 할 수 있습니다?
전혀 없습니까? –