草庐IT

callback_methods

全部标签

ios - 错误 : __tcp_connection_write_eof_block_invoke Write close callback received error - iOS 10

同时向ONVIF相机发送基于XML的API请求。它在iOS9设备上运行良好,但在iOS10上出现“500内部错误”。XCode8控制台打印以下错误消息:2016-09-3012:39:51.295419VCPlugin[278:10183][]nw_socket_get_input_framesrecvmsg(fd12,1024bytes):[54]Connectionresetbypeer2016-09-3012:39:51.301221VCPlugin[278:10228][]nw_socket_write_closeshutdown(12,SHUT_WR):[57]Socketi

ios - 如何从 NSExpression 的 expressionValueWithObject :context method? 获取 float

我已经实现了一个自定义计算器,我在其中使用以下代码来计算类似5+3*5-3的算术表达式。-(NSNumber*)evaluateArithmeticStringExpression:(NSString*)expression{NSNumber*calculatedResult=nil;@try{NSPredicate*parsed=[NSPredicatepredicateWithFormat:[expressionstringByAppendingString:@"=0"]];NSExpression*left=[(NSComparisonPredicate*)parsedleftE

ios - OCMock "expected method was not invoked"即使我自己调用它

我正在尝试在iOS项目中设置一个简单的OCMock单元测试,以熟悉框架。我有一个模拟的DataLoader类,即使我自己调用该方法,我的期望也失败了:-(void)testSimpleMocking{//Mocktheclassidmock=[OCMockObjectniceMockForClass:[DataLoaderclass]];//Overridethe'dispatchLoadToAppDelegate:'tobeano-op[[[mockstub]andReturn:nil]dispatchLoadToAppDelegate:[OCMArgany]];//Expectth

iphone - 抑制警告 : Meta method xx in category from xx conflicts with same method from another category

如何抑制此编译器警告:“...soap+prefix.o”类别中的元方法“prefix”与另一个类别中的相同方法冲突?这是类别soap+Prefix.h:@interfaceSoap(Prefix)+(NSString*)prefix;@end和soap+prefix.m:#import"Soap.h"#import"Soap+Prefix.h"@implementationSoap(Prefix)+(NSString*)prefix{return@"EInspector";}@end顺便说一句,这两个文件是使用SudZc为Web服务包装器自动生成的。附注此警告仅在XCode4.4中发

ios - ([NSAttributedString boundingRectWithSize :options:context:])method can not get the right size within NSTextAttachment

在我的代码中:NSMutableAttributedString*str=[[NSMutableAttributedStringalloc]initWithString:@"12123"];NSTextAttachment*attachment=[[NSTextAttachmentalloc]init];attachment.image=[UIImageimageNamed:@"002"];attachment.bounds=CGRectMake(0,0,20,20);[strinsertAttributedString:[NSAttributedStringattributedStr

iphone - 行动 :@selector(showAlert:) how to pass parameter in this showAlert method?

我正在向我的UITableViewCell添加自定义按钮。在该按钮的操作中,我想调用showAlert:函数并希望在该方法中传递单元格标签。如何在showAlert方法中传递参数:action:@selector(showAlert:)? 最佳答案 如果您在Tableviewcell中使用Button,那么您必须将标签值添加到每个单元格的按钮,并使用id作为参数设置方法addTarget。示例代码:您必须在cellForRowAtIndexPath方法中键入以下代码。{//Settagtoeachbuttoncell.btn1.ta

ios - 抑制链接器警告 : "Meta method X in category from Y overrides method from class in Z"

我有意使用类别来覆盖我知道已经在主类上实现的方法。我知道这通常是设计薄弱的标志——请不要讲课——但在这种情况下我不能干净地子类化。我知道swizzling也可能是一种选择。但是现在,我该如何抑制这个警告?llvm抛出一个编译器警告,我可以禁用它(diagnosticignored"-Wobjc-protocol-method-implementation")。但随后链接器也会提示。Thisasksasimilarquestionbutwaslookingforadifferentanswer.我怎样才能告诉链接器不要提示?谢谢。 最佳答案

iphone - iOS 测试驱动开发 : Testing a method that uses UIVIew animateWithDuration:animations:completion:

我有一个可以触发动画的按钮按下,并在动画完成后更改标签的文本。我想编写一个测试来验证当按下按钮时,标签的文本最终会正确更改。按钮按下IBAction的实现将使用[UIViewanimateWithDuration:animations:completion:]。我显然不希望我的单元测试实际等待0.5秒让动画完成。我考虑过模拟UIView,但将UIView作为ViewController的依赖项注入(inject)似乎很奇怪。此外,我正在使用的模拟框架(OCMockito)似乎不适用于模拟类方法。我还考虑过方法调配或为UIView编写测试类别,并使用一个只调用animations:blo

iOS : ScrollView delegate method inside of CollectionView not call

首先我在.h文件中设置了delegate@interfaceViewController:UIViewController之后只需在collectionview.m文件中调用此方法-(void)scrollViewDidScroll:(UIScrollView*)scrollView{NSLog(@"scrollViewDidScroll");}但不调用这个方法。 最佳答案 简单一点在.m文件中添加以下行yourCollectionView.delegate=self;及下方添加.hUICollectionViewDelegate移

ios - handleTurnEventForMatch :didBecomeActive: callbacks only arriving some of the time

这是thisquestion的后续行动.如果您没有收到对handleTurnEventForMatch:didBecomeActive:的任何回调,请尝试那里的答案。在我的游戏中,我有时只会收到回合事件通知。但是如果我返回到matchMakerViewController并重新加载比赛,状态总是正确的。我的游戏在每个回合中多次上传回合状态。有趣的是,如果另一台设备在对手的回合收到一个通知,那么它就不太可能在同一回合收到更多通知。然而,这不是100%。总的来说,我的互联网连接似乎运行良好。知道是什么原因造成的吗? 最佳答案 终于找到问