Tag: cocoa touch

Retaining rootViewController?

I wonder if someone can help me out with regards to the memory management in the code below. I am particularly interested in rootController, does it get retained when I do initWithRootViewController or does it instead (which is my guess) get retained with window addSubView: I am just curious what is happening … – (BOOL)application:(UIApplication […]

Custom init method in Objective-C, how to avoid recursion?

I want to create a subclass of UINavigationController which always starts with the same root controller. Nothing special, so (to me) it makes perfect sense to override the init method like this: – (id) init { rootController = [[MyController alloc] init]; if (self = [super initWithRootViewController:rootController]) { // do some more initialization } return self; […]

What are controller classes?

This question already has an answer here: UIView vs UIViewController 3 answers When to use a UIView vs. a UIViewController on the iPhone? 8 answers What is a UIViewController 1 answer

Get touch events in a UITextView

Apple does not provide touch event handling for UITextView. The project I’m developing includes notes that can be readable and editable, and I am using a UITextView. Please help me with this problem — how can I get touch events for my project?

App stops receiving data from socket when UI scroll

I have an iPad app that receives data using UDP sockets. And it has a UIWebView to browse webpages. But while doing scroll in the UIWebView, everything freezes and no data is received. I’ve been searching and it has something to do with runloops and threads. But if the UIWebView can’t run in another thread […]

How to define a function macro to check key between multiple localized string files?

I have a Localizable.strings file for my project’s i18n, and a lib uses KYLocalizable.strings. I have considered to make Localizable.strings “subclass” from KYLocalizable.strings, but it cannot as far as I know. So instead, I want to define a function macro like what SDK does: #define NSLocalizedString(key, comment) \ [[NSBundle mainBundle] localizedStringForKey:(key) value:@”” table:nil] #define NSLocalizedStringFromTable(key, […]

AFNetworking deadlock on tasks (tasksForKeyPath)

I’m sure this is something stupid that i’m doing, but after an hour I cannot see it. Maybe you can. Edit: this is on a device (iPhone 5S w/iOS 8.4), not the simulator. I have an iOS 8 app with a DownloadManager, a singleton that subclasses AFHTTPSessionManager using a BackgroundSession. It used to work fine, […]

viewForHeaderInSection disappears when scrolling

I am using a custom header view in my UITableView, but as soon as i begin scrolling down the header disappears instead of staying in place like with the default headers. And it’s not scrolling off the screen either, just completely disappering. viewForHeaderInSection is still being called but the drawRect method of my custom header […]

Why assign nil to IBOutlets in viewDidUnload?

I have a UIViewController that has an IBOutlet for a UILabel with the label wired up in the XIB. #import <Foundation/Foundation.h> @interface MyViewController : UIViewController { IBOutlet UILabel *aLabel; } @end According to iOS Programming: The Big Nerd Ranch Guide (2nd Edition) chapter 7 When [MyViewController] reloads its view, a new UILabel instance is created […]

How to allow the object to be released on callback?

I have a class written in objective C which does some work by connecting to the network. This class does this work in async manner and user gives a delegate which is called once the operation is finished (with response if success or error if failure). The delegate is called when there is no more […]