Skip to content

Commit

Permalink
* [ios] fix crash after returning id type, need to copy here.
Browse files Browse the repository at this point in the history
  • Loading branch information
cxfeng1 committed Dec 23, 2016
1 parent aa50df0 commit 4f5276b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ios/sdk/WeexSDK/Sources/Bridge/JSValue+Weex.m
Expand Up @@ -17,22 +17,23 @@ + (JSValue *)wx_valueWithReturnValueFromInvocation:(NSInvocation *)invocation in
return nil;
}

char returnType[255];
strcpy(returnType, [invocation.methodSignature methodReturnType]);
const char * returnType = [invocation.methodSignature methodReturnType];

JSValue *returnValue;
switch (returnType[0] == _C_CONST ? returnType[1] : returnType[0]) {
case _C_VOID: {
// 1.void
returnValue = nil;
returnValue = [JSValue valueWithUndefinedInContext:context];
break;
}

case _C_ID: {
// 2.id
id result;
[invocation getReturnValue:&result];
returnValue = [JSValue valueWithObject:result inContext:context];
void *value;
[invocation getReturnValue:&value];
id object = (__bridge id)value;

returnValue = [JSValue valueWithObject:[object copy] inContext:context];
break;
}

Expand Down Expand Up @@ -78,7 +79,7 @@ + (JSValue *)wx_valueWithReturnValueFromInvocation:(NSInvocation *)invocation in
case _C_CHARPTR:
case _C_PTR:
case _C_CLASS: {
returnValue = nil;
returnValue = [JSValue valueWithUndefinedInContext:context];
break;
}
}
Expand Down

0 comments on commit 4f5276b

Please sign in to comment.