cocoa-design-patterns

How to share a ManagedObjectContext when using UITabBarController

徘徊边缘 提交于 2019-11-28 16:22:16
问题 I have an iPhone application that has a MainWindow.xib holding a UITabBarController, which in turn has a UINavigationController and a custom UIViewController subclass in its ViewControllers array. The root view controller for the UINavigationController and the custom view controller are both loaded from other xib files. The app uses core data, the stack is initialized in the app delegate (as per the convention). The app delegate adds the UITabBarController to the window: - (void

What's the most efficient way of converting a 10 MB JSON response into an NSDictionary?

亡梦爱人 提交于 2019-11-28 11:26:58
Our app must display a big chunk of data with minimal remote http requests, so we have added an endpoint to our backend that provides all the necessary data as a single json response. This results in ~1.5MB (compressed) or roughly 8 MBs of uncompressed json-formatted text. Not much of a problem, it downloads in 10 - 30 seconds and we're using ASIHTTPRequest to write the whole response to disk. Now comes the fun part - after reading the uncompressed file into a memory mapped string, we use stig's json-framework to convert it into an NSDictionary. This has worked very well for the rest of our

Why not enforce strict singleton application delegate object to use in NIBs?

旧街凉风 提交于 2019-11-28 09:55:12
问题 I just ran myself round in circles, all coming down to having instantiated an app delegate object in a secondary NIB that wasn't the NSMainNibFile . Amazing how having two app delegates kicking around means you have separate managedObjectContexts . Here's a thought-- could I make my application delegate class a singleton? And safely instantiate it in more XIBs? What would that break? Also, there are some mentions on stackoverflow that [[UIApplication sharedApplication] delegate] is a

Core Data backed UITableView with indexing

余生颓废 提交于 2019-11-27 20:20:38
问题 I am trying to implement a Core Data backed UITableView that supports indexing (eg: the characters that appear down the side, and the section headers that go with them). I have no problems at all implementing this without Core Data using: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView; I also have no problem implementing a UITableView that is backed by Core Data without using the

What is Delegate and Delegate Methods

穿精又带淫゛_ 提交于 2019-11-27 11:32:59
问题 Guys anyone please let me know difference between Delegate & Delegate Methods and its differences and its usages ??? 回答1: It's hard to explain, but a delegate performs methods on behalf of another object. A Table View doesn't know what to do when you pick an item in the list. Instead, it has to ask the delegate object a question, specifically, didSelectRowAtIndexPath. The only information the tableview knows is which section and row the user tapped. So the table view gives this information to

What's the most efficient way of converting a 10 MB JSON response into an NSDictionary?

半城伤御伤魂 提交于 2019-11-27 06:12:55
问题 Our app must display a big chunk of data with minimal remote http requests, so we have added an endpoint to our backend that provides all the necessary data as a single json response. This results in ~1.5MB (compressed) or roughly 8 MBs of uncompressed json-formatted text. Not much of a problem, it downloads in 10 - 30 seconds and we're using ASIHTTPRequest to write the whole response to disk. Now comes the fun part - after reading the uncompressed file into a memory mapped string, we use

What exactly is a so called “Class Cluster” in Objective-C?

青春壹個敷衍的年華 提交于 2019-11-26 12:07:01
I was reading that NSArray is just such a thing. Sounds heavy. I have 7 really fat books here on my desk about Objective-C, Cocoa and C. None of them mention Class Cluster at all, at least I can't find it in the Index at the back of the books. So what's that? echo From Apple's docs... . In short it's a design pattern used in the Foundation framework, which is probably why it's not mentioned in ObjC books. A class cluster is an architecture that groups a number of private, concrete subclasses under a public, abstract superclass. The grouping of classes in this way provides a simplified