草庐IT

iphone - 长时间运行的 REST API

我需要连接的后端API大约需要3-4分钟才能返回响应。iOS客户端似乎恰好在60秒(默认值)时超时,我不知道如何延长该超时时间。我曾尝试将NSURLRequest的timeoutInterval设置为较大的数字,并设置Connection:Keep-Aliveheader,但我没有成功。这是我正在使用的代码,省略了一些API细节:NSURL*url=[NSURLURLWithString:@"myAPI"];NSMutableURLRequest*request=[NSMutableURLRequestrequestWithURL:url];[requestsetHTTPMethod:

ios获取平均值同时过滤掉一些对象的最有效方法

我正在尝试获取子实体中某个属性的平均值,同时还尝试仅包含一组选定的记录。我的核心数据模型中有两个实体:Invoice和InvoiceDetail。Invoice:invoiceNum-attributeinvoiceDate-attributeinvoiceDetails-one-to-manyrelationshiptoInvoiceDetailInvoiceDetail:itemAmount-attributeitemType-attributeinvoice-one-to-onerelationshiptoInvoice如果我只想获取整个发票的itemAmount的平均值,我会使

ios - 如何将 AFNetworking AFJSONRequestOperation 包装到单独的数据管理器类中

我刚开始在iOS中使用block,我认为这可能是我问题的症结所在。我只想构建一个简单的静态DataManager类,它的唯一工作就是从我的Restful服务中获取数据。我会从我所有的各种UIViewControllers(或collectionview/tableController)中调用它在我的课上我有一个看起来像这样的函数+(NSArray*)SearchByKeyword:(NSString*)keyword{__blockNSArray*searchResults=[[NSArrayalloc]init];NSString*baseURL=@"http://someURL.c

objective-c - objective-c - 通过 http POST 发送图像

我正在尝试了解如何使用httpPOST和我当前的客户端-服务器协议(protocol)设计来发送图像。从客户端到服务器的所有消息如下例所示,有一个带有参数cmd的cmd字符串和一些更相关的命令参数。例如,这是我向服务器发送短信的方式:-(void)sendMessagesWithText:(NSString*)textfromUser:(NSString*)userId{NSString*url=SERVER_URL;NSMutableURLRequest*request=[[[NSMutableURLRequestalloc]init]autorelease];[requestset

iphone - 通过 ASIFormDataRequest 将 Mp4 视频发送到 PHP 服务器

我在这里发送文件路径或带有一些参数的文件。但是服务器没有得到视频。那么该代码有什么问题吗?或者任何你想添加的东西。那么请告诉我。您想告诉我哪里出现错误或响应设置的任何委托(delegate)方法。NSString*path=[[NSBundlemainBundle]pathForResource:@"hangover"ofType:@"mp4"];ASIFormDataRequest*request=[ASIFormDataRequestrequestWithURL:[NSURLURLWithString:@"http://156.75.28.172:52/aircas/RestSer

iphone - 从完成的 ASIHTTPRequest 获取 postValue

我想知道如何从完成的ASIHTTPRequest中检索发布值。当我执行请求时,我会这样做:[requestsetPostValue:uniqueIDforKey:@"bookUniqueId"];NSFileManager*fileManager=[[NSFileManageralloc]init];if(![fileManagerfileExistsAtPath:tempDir]){[fileManagercreateDirectoryAtPath:tempDirwithIntermediateDirectories:YESattributes:nilerror:nil];}[fil

objective-c - iOS:CFRunLoopRun() 函数困惑

我读过有关CFRunLoop的内容,但仍然对它有些困惑。我遇到了一段代码,我想自己澄清一下:NSMutableURLRequest*request=[[NSMutableURLRequestalloc]init];[requestsetURL:[NSURLURLWithString:[NSStringstringWithFormat:url]]];[requestsetHTTPMethod:@"POST"];[requestsetValue:@"application/xml"forHTTPHeaderField:@"Content-Type"];[requestsetValue:po

iphone - 使用sendSynchronousRequest时在ios中获取http响应码

这个问题在这里已经有了答案:howdoIcheckanhttprequestresponsestatuscodefromiOS?(2个答案)关闭8年前。我有一个不使用任何第三方位的工作httpGET,我是iOS的新手,所以最初设置起来很困难。我的代码如下所示:-(NSString*)SendGetRequestToRest:(NSString*)urlEndString{NSString*userName=@"userN";NSString*password=@"PassW";NSString*urlBaseString=@"http://someurl.co.uk/";NSStrin

ios - 如何在 AFNetworking 2.0 中做一个简单的 form-urlencoded POST 请求?

如何在AFNetworking2.0中复制此NSURLConnection代码?NSString*post=@"key=xxx";NSData*postData=[postdataUsingEncoding:NSASCIIStringEncodingallowLossyConversion:YES];NSString*postLength=[NSStringstringWithFormat:@"%d",[postDatalength]];NSMutableURLRequest*request=[[NSMutableURLRequestalloc]init];[requestsetURL

objective-c - 确定弱引用对象是否已被释放

我使用下面的代码来下载图片:-(void)downloadImageAtUrl:(id)urlandDelegate:(id)delegate_{NSURL*correctUrl=nil;if([urlisKindOfClass:[NSStringclass]])correctUrl=[NSURLURLWithString:[NSStringstringWithFormat:@"%@%@",kHostURL,[urlsubstringFromIndex:1]]];elsecorrectUrl=url;__blockASIHTTPRequest*request=[ASIHTTPReque