草庐IT

NStimer、CADisplayLink、dispatch_source_t

全部标签

Automapper 6.1.1使用MemberList.Source:发现未覆盖的会员

我在Automapper中遇到以下错误:Unmappedmemberswerefound.Reviewthetypesandmembersbelow.Addacustommappingexpression,ignore,addacustomresolver,ormodifythesource/destinationtypeFornomatchingconstructor,addano-argctor,addoptionalarguments,ormapalloftheconstructorparameters配置看起来像这样:cfg.CreateMap(MemberList.Source).E

iphone - 在没有 NSTimer 的情况下每隔几秒调用一次获取当前坐标

我知道如何使用NSTimer进行此操作,但我不想每隔几秒钟就没有计时器就获取当前的iPhone坐标。我无法使用计时器,因为我在应用程序处于后台时获取坐标。我尝试过一些东西,但这不是每10秒,而是每秒调用一次,因为我不想。我在这里做错了什么?-(void)locationManager:(CLLocationManager*)managerdidUpdateLocations:(NSArray*)locations{CLLocation*loc=[locationsobjectAtIndex:0];NSDate*eventDate=loc.timestamp;NSTimeInterval

iphone - NSTimer 暂停不起作用

我设置了三个按钮,分别是开始、停止、暂停。并给NSTimer控制来计算。开始停止按钮工作正常给了我开始和停止时间但是pause按钮没有给我准确的时间。它实际上是暂停时间..但是再次开始它添加了暂停定时和显示[ay。supoose我在开始的5秒暂停并等待5秒然后按开始......它应该显示5......但显示10..-(void)start:(NSTimer*)timer{if(_timer==nil){startDate=[NSDatedate];_timer=[NSTimerscheduledTimerWithTimeInterval:0.25target:selfselector:

ios - dispatch_once 与静态

我目前正在为我的应用程序编写一个帮助程序类。助手类将返回全局可访问的变量。我创建了一个简单的助手,如下所示:@interfaceMyHelper:NSObject{}+(id)sharedHelper;+(NSMutableArray*)employers;+(id)sharedHelper{staticMyHelper*sharedHelper=nil;staticdispatch_once_tonceToken;dispatch_once(&onceToken,^{sharedHelper=[[selfalloc]init];});returnsharedHelper;}+(NSM

ios - 在 __dispatch_call_block_and_release 上崩溃

我有一个iOS应用程序,但我遇到了相当多的崩溃。而且它似乎与我的代码无关。你知道为什么应用程序会因此而崩溃吗?我可以做些什么来防止这些崩溃。Thread9Crashed:1libobjc.A.dylib_objc_msgSend+162libdispatch.dylib__dispatch_call_block_and_release+133libdispatch.dylib__dispatch_queue_drain+2394libdispatch.dylib__dispatch_queue_invoke$VARIANT$mp+415libdispatch.dylib__dispat

ios - 在 dispatch_async 之后顺序调用代码

我在iOS中做一些定制,我正在子类化一个异步执行方法的系统类(大概使用dispatch_async)示例代码:-(void)originalAsyncMethod{[superoriginalAsyncMethod];dispatch_async(dispatch_get_main_queue(),^{//dosomethingthatneedstohappenjustafteroriginalAsyncMethodfinishesexecuting});}有没有一种方法可以确保我的自定义代码在异步super方法执行后运行? 最佳答案

ios - dispatch_async 并非一直有效

我有以下代码...-(void)SetSerialNumber{NSLog(@"SetSerialNumber");NSString*serialNum=textFieldSecond.text;if(textFieldSecond.text==nil){[selfperformSelectorOnMainThread:@selector(display:)withObject:@"PleaseEntertheserialnumber"waitUntilDone:YES];return;}dispatch_async(dispatch_get_global_queue(DISPATCH

ios - 带有 UITableView 的 NSTimer

我有UIView和按钮Start,UILabel有我的NSTimer时间和UITableView有时间记录。问题是当我滚动我的tableview-NSTimer卡住时,为什么我可以对它们异步工作?我的代码:-(IBAction)startTimer{_startButton.hidden=YES;_stopButton.hidden=NO;isRun=YES;UIBackgroundTaskIdentifierbgTask=UIBackgroundTaskInvalid;UIApplication*app=[UIApplicationsharedApplication];bgTask=

ios - 从另一个 View Controller 停止 dispatch_async 内的无限循环

我正在构建一个简单的聊天室应用程序,其中有一个NSURLConnectionsendSynchronousRequest:通过长轮询向服务器发送请求。我想显示一个在后台运行时不断向我的用户更新聊天提要的流。我的应用程序还允许用户更改他们的聊天室,因此我需要关闭一个NSURLConnection并为相应的提要打开另一个。我目前的实现如下://inViewController.mdispatch_queue_tconcurrentQueue=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);dispatch_async

ios - 什么时候使用 dispatch_get_main_queue

我在iOS中学到了一条全局规则->永远不要阻塞主线程。但是,有几次我遇到了违反此规则的开源代码片段。下面是两个这样的例子:以下函数取自https://github.com/piwik/piwik-sdk-ios/blob/master/PiwikTracker/PiwikTracker.m-(void)startDispatchTimer{//Runonmainthreadrunloop__weaktypeof(self)weakSelf=self;dispatch_async(dispatch_get_main_queue(),^{[weakSelfstopDispatchTimer