objective c - Casting id to pointer to an NSError pointer (NSError **) -
i have nserror ** stored in array (so can such array[0]). i'm trying cast variable:
nserror * __autoreleasing *errorpointer = (nserror * __autoreleasing *)array[0];
so can access underlying object *errorpointer.
however, xcode complains cast of objective-c pointer 'nserror *__autoreleasing *' disallowed arc. there way object without turning off arc?
neither stub:withblock: method or of supporting infrastructure stuffing double pointer nsarray. array won't take non-objects, , pointer object not object. there's else going on.
this requires digging code figure out. value put array? that's in -[kwstub processinvocation:], , it's done apparently using method added nsinvocation ocmock, getargumentatindexasobject:. in method, invocation uses switch check type of argument requested, , boxes if necessary.
the relevant case here last one, argument type ^, meaning "pointer". sort of argument wrapped in nsvalue; therefore, array recieved block contains, not double pointer itself, nsvalue representing outer pointer. need unbox it.
that should this:
nsvalue * errval = array[1]; nserror * __autoreleasing * errptr = (nserror * __autoreleasing *)[errval pointervalue];
Comments
Post a Comment