小编iam*_*mug的帖子

如何使用AFNetworking下载文件并将其保存到文档目录?

我正在使用AFNetworking库.我无法弄清楚如何下载文件并将其保存到文档目录.

iphone ios afnetworking

50
推荐指数
3
解决办法
4万
查看次数

AFNetworking上传文件

是否有人使用AFNetworking完全上传文件.我在互联网上找到了一些代码,但它不完整.我找到的代码在这里:

AFHTTPClient *client= [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://my.client.server.com"]];


NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters setObject:[fieldName text] forKey:@"field01_nome"];
[parameters setObject:[fieldSurname text] forKey:@"field02_cognome"];



NSMutableURLRequest *myRequest = [client multipartFormRequestWithMethod:@"POST" path:@"/Contents/mail/sendToForm.jsp" parameters:parameters constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
    [formData appendPartWithFileData:myNSDataToSend mimeType:@"image/jpeg" name:@"alleagto"];
}];


AFHTTPRequestOperation *operation = [AFHTTPRequestOperation HTTPRequestOperationWithRequest:myRequest success:^(id object) {
    NSLog(@"Success");

} failure:^(NSHTTPURLResponse *response, NSError *error) {
    NSLog(@"Fail");

}];


[operation setUploadProgressBlock:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
    NSLog(@"Sent %d of %d bytes", totalBytesWritten, totalBytesExpectedToWrite);

}];

queue = [[[NSOperationQueue alloc] init] autorelease];
[queue addOperation:operation];
Run Code Online (Sandbox Code Playgroud)

我在以下几行中收到错误:

 [formData appendPartWithFileData:myNSDataToSend mimeType:@"image/jpeg" …
Run Code Online (Sandbox Code Playgroud)

iphone ios afnetworking

14
推荐指数
1
解决办法
2万
查看次数

如何使用相同的应用程序找到Facebook好友

我正在创建一个应用程序,并希望使用该应用程序的人在Facebook上使用相同的应用程序查找朋友.对此的任何帮助都会很棒.

我知道这可以做到.我在Instagram和Tiger Woods 12上看过它.

iphone facebook

12
推荐指数
1
解决办法
1万
查看次数

如何使用AFNetworking上传多个文件

我可以上传单个文件而没有任何问题,但现在我发现我需要上传1个或更多文件,有人知道如何使用AFNetworking吗?

非常感激任何的帮助.

iphone afnetworking

10
推荐指数
1
解决办法
8722
查看次数

AFNetworking,AFHTTPRequestOperation完成块缓慢触发代码

我正在使用AFNetworking注册新用户,一切正常,但在下面的块我有一些问题:

    AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:myRequest] autorelease];
operation.completionBlock = ^ {
    if ([operation hasAcceptableStatusCode]) {
        NSLog(@"success");
        username.backgroundColor = [UIColor yellowColor];
    } else {
        switch ([operation.response statusCode]) {
            case 421:                  
            {
                NSLog(@"Username taken.");
                username.backgroundColor = [UIColor yellowColor];   
            }
                break;
            default:
                break;
        }
    }
};
Run Code Online (Sandbox Code Playgroud)

基本上我的服务器端脚本做了一些验证并激活了HTTP状态代码(我知道421不是有效的).这使我能够知道服务器上出了什么问题,这很有效.

我的问题是,当响应返回它触发的NSLog(@"success");NSLog(@"Username taken.");直线距离,但相当多的几秒钟,任何其他代码火灾后.

有人可以对此有所了解吗?

iphone ios5 afnetworking

9
推荐指数
1
解决办法
2万
查看次数

iPhone SDK UIBarButton内存泄漏

我一直在写一个工作正常,但我正在用仪器测试泄漏,并遇到来自UIBarButtonContent的漏洞,这里是违规行.

     UIButton *searchbutton =  [UIButton buttonWithType:UIButtonTypeCustom];
 [searchbutton setImage:[UIImage imageNamed:@"searchbutton.png"] forState:UIControlStateNormal];
 [searchbutton addTarget:self action:@selector(search) forControlEvents:UIControlEventTouchUpInside];
 [searchbutton setFrame:CGRectMake(0, 0, 29,29)];
 self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:searchbutton];
Run Code Online (Sandbox Code Playgroud)

我应该在任何地方发布searchButton或self.navigationItem.rightBarButtonItem.

一些帮助会很棒.

干杯

iphone memory-leaks ios4

1
推荐指数
1
解决办法
812
查看次数

我如何检测TTTAttributedLabel中的链接?

我有一个表视图,在一些单元格中有链接,我想让用户点击这些链接并在webView中查看它们(我已经制作了).我不想使用行选择事件,因为单元格中可能有多个链接.我遇到了TTTAttributedLabel,并认为这将是理想的.我不需要在单元格中为文本添加任何样式,我只需要检测链接并捕获click事件以打开我的webview.

任何帮助将不胜感激.

iphone objective-c ios

0
推荐指数
1
解决办法
2405
查看次数

标签 统计

iphone ×7

afnetworking ×4

ios ×3

facebook ×1

ios4 ×1

ios5 ×1

memory-leaks ×1

objective-c ×1