artifacts / AFCache

AFCache is an HTTP cache for iOS and OSX seeking towards full RFC2616 compliance
Apache License 2.0
361 stars 43 forks source link

no callback when launched from background thread #17

Closed esromneb closed 11 years ago

esromneb commented 11 years ago

I am making a call like this: [[AFCache sharedInstance] cachedObjectForURL: [NSURL URLWithString:aUrl] delegate: self selector: @selector(connectionDidFinish:) didFailSelector: @selector(connectionDidFail:) options: 0 userData: (id)type username: nil password: nil];

When I make this call on the main thread, everything works great, but If I make this call from a thread that is in the background like this:

[self performSelectorInBackground:@selector(sel) withObject:nil];

I never get the callback. Any ideas here?

nsc commented 11 years ago

AFCache isn't set up to be thread-safe, i.e. you can not use it from more than one thread.

esromneb commented 11 years ago

Great, thanks for this info!

rondss commented 10 years ago

Hi - is it still the case that AFCache can only be used from a single thread? I've inherited some code that uses AFCache and am seeing issues when accessed from different threads:

* Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSArrayM: 0x29a2350> was mutated while being enumerated.'

Thanks!

artifacts commented 10 years ago

Hi,

yes, AFCache is still not thread-safe.

rondss commented 10 years ago

Thanks for the very quick confirmation - appreciated.