nsrunloop

Error at NSRunLoop after returning from thread method with NSAutoreleasePool

陌路散爱 提交于 2019-12-12 01:37:31
问题 I am getting an EXC_BAD_ACCESS error after I return from a thread method in which I have set up an NSAutoreleasePool. The place of failure is at a call to NSRunLoop. I am trying to wrap a 3rd party library consisting mainly of a class (let's call it the Connection class) and its delegate such that it will behave synchronously instead of asynchronously to client classes. The wrapping class, called NFCConnection, conforms to the delegate protocol and is passed to Connection's setDelegate method

Obj- C Configure Run Loop for NSDistributionNotificationCenter

老子叫甜甜 提交于 2019-12-11 10:05:13
问题 I am making a simple IPC module for my helper task, I decided to use NSDistributionNotificationCenter because of it's simplicity. However I think that it need to be run in a runloop which I don't have, So I need to create a RunLoop. I have read the documentation about RunLoops here https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html However it is not clear for me, how should I do this RunLoop only for receiving and

SIGSEGV in background thread NSRunLoop runMode:beforeDate:

旧时模样 提交于 2019-12-11 09:08:45
问题 I am using background threads with following pattern: // Defined in .h-file as ivar BOOL backgroundThreadIsAlive; // .m file static NSThread *backgroundThread = nil; - (id)init { if (self = [super init]) { if (backgroundThread == nil) { backgroundThreadIsAlive = YES; backgroundThread = [[NSThread alloc] initWithTarget:self selector:@selector(threadMain:) object:nil]; [backgroundThread start]; } } return self; } - (void)threadMain:(id)data { NSRunLoop *runloop = [NSRunLoop currentRunLoop];

NSURLConnection messes up iPad memory

北城余情 提交于 2019-12-11 03:27:11
问题 we build an iPad app that downloads a bunch of data and PDF documents from a web service (data first, documents later in the background). To do so, we use SOAP via HTTP(S) requests. It works fine and altogether, the app is running well. Problem is, if there are too many documents to download at some point the app crashes. Using Instruments I figured out that it is a memory issue, particularly NSRegularExpression and NSRunLoop. (I'm using ARC) I could improve my code to optimize the

On NSRunLoop, clarification needed

不问归期 提交于 2019-12-11 02:48:08
问题 When i Logger *logger = [Logger new]; NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; __unused NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:logger startImmediately:YES]; ... nothing happens. Delegate methods are not called until i [[NSRunLoop currentRunLoop]run]; I would have thought that startImmediately:YES would do exactly that. 回答1: async callbacks require an NSRunLoop. See: Cocoa:

Is object that calls performSelector:withObject:afterDelay get retained by the NSRunLoop?

亡梦爱人 提交于 2019-12-11 01:06:11
问题 I have a certain object that perform a "Refresh" every X seconds. ("The Updater") The way I'm doing this repetitive update is by calling performSelector:withObject:afterDelay and in my selector I'm re-scheduling as necessary. Of course I have a method to stop these invokations by calling cancelPreviousPerformRequests . The problem is that this "Updater" is never being deallocated. There is only one other object that retaining the Updater (AFAIK), and the retaining object is being deallocated

Calling NSURLConnection inside dispatch_async and reading didReceiveResponse in mainRunLoop in iPhone development

元气小坏坏 提交于 2019-12-10 20:57:26
问题 What I am trying to do is getting response for following method - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { } after calling this NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [conn scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [conn start]; inside a dispatch_async(); But the connection method is not calling. But when I run the NSURLConnection code outside the dispatch

AVPlayerStatus vs AVPlayerItemStatus

99封情书 提交于 2019-12-10 14:09:06
问题 The issue is that player.status returns AVPlayerStatusReadyToPlay a full 2 seconds before player.currentItem.status returns AVPlayerItemStatusReadyToPlay . Does anyone have any helpful explanations as to why this is happening? This is just sample code to show the basic idea of what's happening so if there are any typos or whatever please ignore them. - (void) someMethod { player = [[AVPlayer alloc] initWithURL:someValidURL]; [player play]; NSTimer *timer = [NSTimer timerWithTimeInterval:0.1

Multiple locks on web thread not allowed! Please file a bug. Crashing now

▼魔方 西西 提交于 2019-12-10 13:34:11
问题 i make a url-Request and waiting for the answer with I start the request, then waiting until synchronousOperationComplete=TRUE NSRunLoop *theRL = [NSRunLoop currentRunLoop]; while (!synchronousOperationComplete && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]); then I return the response all seems to be ok,i get the response and everything is working normal, but when I close the app i get: bool _WebTryThreadLock(bool), 0x227f40: Multiple locks on web thread not

How to wait in NSThread until some event occur in iOS?

喜夏-厌秋 提交于 2019-12-09 09:20:15
问题 How to wait inside the NSThread until some event occur in iOS? eg, We created a NSThread and started a thread loop. Inside the thread loop, there is condition to check whether the message queue has any messages. If there is a message, then it will call the corresponding method to do some operation, else it should wait until the message queue gets populated with a new message. Is there any API or methods available to wait until some event occur? For Example NSThread *thread = [NSThread alloc].