Objective-C: Instance Variable in Category

A category can not declare additional instance variables but since OS X 10.6 and iOS 3.1 you can work around this with associative references. You can use associative references to simulate the addition of object instance variables to an existing class. Using associative references, you can add storage to an object without modifying the class … Read more

Does AFNetworking have backgrounding support?

EDIT: As of AFNetworking 1.0RC1, this is an explicit feature. AFURLConnectionOperation now has the method setShouldExecuteAsBackgroundTaskWithExpirationHandler:, which transparently manages all of this for you. It’s an implicit feature, so I didn’t really think about advertising it. All you’d need to do is: – (void)applicationWillResignActive:(UIApplication *)application { __block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^(void) { [application endBackgroundTask:backgroundTaskIdentifier]; … Read more

Fix warning “Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code

Replying to myself: My understanding of the documentation says that using keyword block and setting the variable to nil after using it inside the block should be ok, but it still shows the warning. __block ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:… [request setCompletionBlock:^{ NSDictionary *jsonDictionary = [[CJSONDeserializer deserializer] deserialize:request.responseData error:nil]; request = nil; // …. … Read more