AlanQuatermain / AQGridView

A grid view for iPhone/iPad, designed to look similar to NSCollectionView.
http://quatermain.tumblr.com/
BSD 3-Clause "New" or "Revised" License
2.37k stars 450 forks source link

Fixed XCode 6 compiler error #211

Open carlospuk opened 10 years ago

carlospuk commented 10 years ago

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 carl.partridge@fatattitude.com

nirgolan commented 9 years ago

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

ragingprodigy commented 9 years ago

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

carlospuk commented 9 years ago

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 commented 9 years ago

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

carlospuk commented 9 years ago

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 commented 9 years ago

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;