我正在将iOS应用程序从Xcode4迁移到Xcode7 (beta 4)。对AFNetworking
的依赖通过Pods自动解析。AFNetworking
2.0与AFNetworking
1.0不向后兼容,因此我修改了部分源代码。这里是
下期
/Api/ApiClient.m::: error: unexpected interface name 'NSData': expected expression
NSData* callerData = [@"http://nikyotis.xyz" dataUsingEncoding:NSUTF8StringEncoding];
^
/Api/ApiClient.m::: error: use of undeclared identifier 'callerData'
NSData* callerData = [@"http://nikyotis.xyz" dataUsingEncoding:NSUTF8StringEncoding];
在上面示例的第280行
将NSData替换为NSString将导致以下错误
原始AFNetwork-1.0代码
我试图通过用//1替换例程来迁移到AFNet-2.0
或//2
百无所成
发布于 2015-08-04 09:46:51
我认为NSData编译器错误是一个红色鲱鱼。问题是,只为“failure”参数提供了代码块,而不是“constructingBodyWithBlock”参数。
试一试如下:
NSMutableURLRequest* request =
[ [ApiManager sharedManager]
POST:@"/v1/exec"
parameters:nil
constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
{
// Code to form the body of the form is here
//NSData* callerData = [[NSData alloc] init];
NSData* callerData = [@"http://nikyotis.xyz" dataUsingEncoding:NSUTF8StringEncoding];
[formData appendPartWithFormData:callerData name:@"caller"];
[formData appendPartWithFileData:fontData name:@"front" fileName:@"front" mimeType:@"application/octet-stream"];
[formData appendPartWithFileData:sideData name:@"side" fileName:@"side" mimeType:@"application/octet-stream"];
}
success:^(AFHTTPRequestOperation *operation, id responseObject)
{
// Operation success code goes here
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
// Operation failed code goes here
}
];
为任何格式化问题道歉-有标记麻烦。
发布于 2015-08-05 02:37:40
问题是不稳定的(贝塔)
OS X El Capitan 10.11 Beta (15A244d) \ Xcode版本7.0 beta 4 (7A165t)
我在用。我期待的是..。
以上代码在稳定的Yosemite n Xcode 6.4上运行良好。
https://stackoverflow.com/questions/31697762
复制相似问题