我从github下载了Drupal-iOS-SDK 我还下载了AFNetworking文件from here。
然后我将文件添加到我的项目中,但它显示了一个奇怪的错误
不兼容的块指针类型将'void(^)(NSInteger,NSInteger,NSInteger)'发送到'void(^)类型的参数(NSInteger,long long,long long)'
这段代码:
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setUploadProgressBlock:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
NSLog(@"Sent %d of %d bytes", totalBytesWritten, totalBytesExpectedToWrite);
}];
有谁知道这意味着什么?
答案 0 :(得分:2)
当NSInteger
预期有一个setUploadProgressBlock
(无符号整数)和两个NSUInteger
参数
long long
作为参数发送给totalBytesWritten
totalBytesExpectedToWrite
和long long
需要属于AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
NSLog(@"Sent %d of %d bytes", totalBytesWritten, totalBytesExpectedToWrite);
}];
类型,因为它是如何定义的,而非`NSInteger'。您的代码应如下所示:
long long
您可能还需要相应地修改NSLog,因为它已设置为NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
,因此编译器不会抱怨。
{{1}}