Reputation: 127
I am getting the error:
Incompatible block pointer types assigning to 'void (^__strong)(NSString *__strong, NSInteger)' from 'void (^__strong)(NSString *__strong, int)'
For this code:
-(void)showInView:(UIView *)view withCompletionHandler:(void (^)(NSString *, int))handler{
_completionHandler = handler;
}
Where:
@property (nonatomic, strong) void(^completionHandler)(NSString *, NSInteger);
This seems like it should be a really, really easy fix, but I don't know enough to get it to work.
Upvotes: 1
Views: 3174
Reputation: 130193
I take it you're trying to build this for a 64 bit target? NSInteger is defined as follows:
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
So, when building for a 64 bit platform, NSInteger is replaced by the long
type, which causes this error, because you're trying to assign to block that takes an int as a parameter, to a property that's expecting a block that takes a long. You should be using this:
-(void)showInView:(UIView *)view withCompletionHandler:(void (^)(NSString *, NSInteger))handler{
_completionHandler = handler;
}
Upvotes: 5