Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed XCode 6 compiler error #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

carlospuk
Copy link

When compiling in the newest version of Xcode (beta), the compiler throws an error in AQGridView.m when performing the hit test using the IMP calls.

I've replaced this code with NSInvocation calls instead; it now compiles and runs OK.

Signed-off-by: Carl Partridge [email protected]

Replaced explicit call to IMP with NSInvocation methods

Signed-off-by: Carl Partridge <[email protected]>
@nirgolan
Copy link

that's awesome @carlospuk !
By the way, the problem is with Xcode 6 + 64 bit architecture (worked well on XC6 with 32 bit).

@ragingprodigy
Copy link

Thanks for this. Saved me a lot. Was looking for a solution for almost 3 hours.

@carlospuk
Copy link
Author

Glad it helped. You should consider moving your implementations over to UICollectionView these days; I took the plunge recently and it's a fairly simple migration path, a lot of the implementation details are very similar.

@kyosold
Copy link

kyosold commented Jul 6, 2015

When i use this code instead of imp, i popViewControllerAnimated, after dealloc,i get EXC_BAD_ACCESS at function dealloc in AQGridViewCell.m

@carlospuk
Copy link
Author

You're on borrowed time. You really should consider moving your implementation over to UICollectionView these days; I took the plunge recently and it's a fairly simple migration path, a lot of the implementation details are very similar.

@kyosold
Copy link

kyosold commented Jul 7, 2015

I found a way to fix it from internet, i don't understood, but it was worked, when i choose this code, it doesn't crash.

I delete this code:
/*
// Get return value
NSValue * ret_val = nil;
NSUInteger ret_size = [signature methodReturnLength];

if(  ret_size > 0 ) {

    void * ret_buffer = malloc( ret_size );

    [invocation getReturnValue:ret_buffer];

    ret_val = [NSValue valueWithBytes:ret_buffer objCType:[signature methodReturnType]];

    free(ret_buffer);
}

// Copy the value into our UIView object
UIView * returnedView = nil;
[ret_val getValue:&returnedView];

return returnedView;

*/

And use this code:
CFTypeRef result = NULL;
[invocation getReturnValue:&result];
UIView *returnView = (__bridge UIView *)result;

return returnView;

The whole code:
// Use NSInvocation to do this instead
SEL hitSelector = @selector(hitTest:withEvent:);
NSMethodSignature * signature = [self methodSignatureForSelector:hitSelector];
NSInvocation * invocation = [NSInvocation invocationWithMethodSignature:signature];

[invocation setTarget: self];
[invocation setSelector:hitSelector];

[invocation setArgument:&point atIndex:2];
[invocation setArgument:&event atIndex:3];

// Invoke!
[invocation invoke];

CFTypeRef result = NULL;
[invocation getReturnValue:&result];
UIView *returnView = (__bridge UIView *)result;

return returnView;

Method method = class_getInstanceMethod( [UIView class], @selector(hitTest:withEvent:) );
IMP imp = method_getImplementation( method );
return ( (UIView *)imp(self, @selector(hitTest:withEvent:), point, event) ); // -[UIView hitTest:withEvent:]
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ddd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants