2012-09-10 175 views
2

我从github 下载了Drupal-iOS-SDK,并且我还下载了AFNetworking文件from here将drupal-ios-sdk与iPhone应用程序集成的问题

然后,我添加文件到我的项目,但它显示了一个奇怪的错误

Incompatible block pointer types sending 'void (^)(NSInteger, NSInteger, NSInteger)' to parameter of type '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); 
    }]; 

有没有人有任何想法,这是什么意思?

回答

2

您发送3个NSInteger S作为参数来setUploadProgressBlock时,它的预期一个NSUInteger(无符号整数)和两个long long参数

totalBytesWrittentotalBytesExpectedToWrite需要被long long类型的,因为这是他们是如何定义的,而不是`NSInteger的的。你的代码应该是这样的:

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 
[operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { 
    NSLog(@"Sent %d of %d bytes", totalBytesWritten, totalBytesExpectedToWrite); 
}]; 

您可能还需要修改您的NSLog因此现在,它的设置为long long所以编译器不抱怨。

NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite); 
+1

我刚尝试过了,现在,它给出了一个类似的错误:不兼容的块指针类型发送“无效(^)(NSInteger的,长长,长长)”来类型的参数“无效(^)( NSInteger,long long long long)' – Shahnawaz

+0

我已经更新了一下我的代码,确保你做了一个干净的构建,并且肯定使用了LLVM编译器为您的项目和目标 –

+1

我清理了我的解决方案并按照你的要求做了,它只会从NSLog中删除警告,但它仍然显示错误。也许你应该去上面的Drupal-iOS-SDK链接并将其集成到一个空白项目中。只是建立它,看看为什么你会得到这样的错误。谢谢! – Shahnawaz

相关问题