iphone - drupal-ios-sdk 与 iPhone 应用程序集成时出现问题

标签 iphone ios drupal drupal-modules

我从 github 下载了 Drupal-iOS-SDK 我还下载了 AFNetworking 文件 from here .

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

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);
    }];

有人知道这意味着什么吗?

最佳答案

您正在将三个 NSInteger 作为参数发送给 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);

关于iphone - drupal-ios-sdk 与 iPhone 应用程序集成时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12350464/

相关文章:

ios - 转换 ARC 时出现 Lipo 错误

iphone - Google 阅读器中的多个标签/文件夹

ios - 如果用户在负方向平移 x 和 y,UIPanGestureRecognizer 不会切换到状态 "End"或 "Cancel"

iOS10:收到推送通知后无法获取当前用户通知设置

php - 两个PHP网站实现单点登录的策略是什么?

drupal - Ubercart 2.0 - 允许小数数量的代码更改列表?

iphone - CGContextAddArc 真的那么慢吗(与用几条线绘制的圆相比)

ios - 使用 Monotouch 和 iOS 从服务中提取数据 (JSON) 的理想方式?

Drupal 8 : Video Embed Field library load order for colorbox responsive video

iphone - 您可以在 iPhone 应用程序中做哪些最耗电的事情?