@Dave の助けを借りて、含まれている型に関係なく NSArray からポインターを抽出し、いくつかの複雑な操作を実行してから、void *型を使用してポインターを再構築するソリューションを最終的に見つけました。
Objective-C++ 機能を有効にするには、.m ファイルの名前を .mm に変更するだけです。
void *array[[self count]]; //create an empty void* array
for (uint i = 0; i < [self count]; i++)
{
int address = (int)[self objectAtIndex:i];
array[i] = (void *)address; //insert NSObjects pointers into void* array
}
void* 配列から NSObjects を取得するには、次のように進めます。
NSMutableArray *doneAr = [[NSMutableArray alloc] init]; //create a NSMutableArray
for (uint i = 0; i < [self count]; i++)
{
void *tmp = (void **)done + i; //extract the pointer in the void* array
NSString *strTmp = (NSString *)(*((Class *)tmp)); //convert it back to origin type (here NSString *)
[doneAr addObject:strTmp]; //add it back to the previously created NSMutableArray
}
この回答が将来の問題に役立つことを願っています。C++ 実装で私のように NSComparator を使用する場合は、.m ファイルの名前を .mm ファイルに変更して、Objective-C++ 機能を使用できるようにします。次に、必要なものをインポートして使用します(たとえば、NSComparator)。