cocoa-design-patterns

One UITableView - Multiple DataSource, best design pattern?

This seems like a typical problem, but I have a UITableView that has identical behavior for two separate data sources. What is the best way of going about designing the class hierarchy to have as little duplication and if/else conditions? The view controller is going to do the same exact thing to both data sources, they're just unique in...

How do I serialize a simple object in iPhone sdk?

I have a dictionary of objects; they are all POCO objects that should be serializable. What technique should I look at for writing these to disk. I'm looking for the simplest option to write a few lists to save state. I think I have 3 options. plist files. However this seems to be limited to only storing predefined objects (strings...

Patterns for accessing remote data with Core Data?

I am trying to write a Core Data application for the iPhone that uses an external data source. I'm not really using Core Data to persist my objects but rather for the object life-cycle management. I have a pretty good idea on how to use Core Data for local data, but have run into a few issues with remote data. I'll just use Flickr's API ...

Core Data: Design questions. Object wrappers or not?

I'm designing my first project using Core Data (for iPhone) and Im having some issues that might be related with my design approach. I'm doing an application that allows the user to create an Order (let's say for a restaurant). I'm using the graphic designer to model my persistence object (i.e. OrdeMO). I add MO to the ead of each name ...

Core Data backed UITableView with indexing

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; - (NSA...

Best practice for assigning new objects to retained properties?

I am using Core Data for my iPhone app. My attributes are set with retained properties. For example, a "number" attribute in a "Thing" entity: #import <CoreData/CoreData.h> @interface Thing : NSManagedObject { } @property (nonatomic, retain) NSNumber * number; @end @implementation Thing @dynamic number; @end When working with...

Customize a data-driven TableView

I have a grouped tableview that is populated with XML data in one section. What I would like to do is create another section prior to the data driven one, and apply an action to it. Example: The user is presented with a button that says "use your current location" (manually created section) and below that is a list of countries the use...

tableView: titleForHeaderInSection: causing crash

For some reason, the tableView: titleForHeaderInSection: method is causing the application to crash without giving any details as to why. I know it is this method because when I comment it out, the table loads, just without headers obviously. - (void)viewDidLoad { [super viewDidLoad]; NSArray *monthArray = [NSArray arrayWithObj...

Exchange data between two iPhone child views

Been researching how to send data from one child view to another child view. The application has several views, where one is kind of real-time Settings view. Changes in settings should effect stuff inside other views. NSUserDefaults seems to be popular, but I don't want persistent data nor automatic saving into database/file. Looks like...

What is Delegate and Delegate Methods

Guys anyone please let me know difference between Delegate & Delegate Methods and its differences and its usages ??? ...

combining flipsideview and navigationview

when i am trying to combine flipsideview and navigation view i am getting following error "request for member 'delegate' is something not in a structure or union" on the line controller.delegate = self; ...

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

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? ...

Confused in getting the ManagedObjectContext from AppDelegate

I've been looking at the documentation on Core Data and trying to figure out how to arrange the Core Data Stack so it's accessible to all of my UITableViewControllers. All the examples provided by Apple show this to be implemented on the AppDelegate yet the documentation doesn't recommend this approach because it's too ridged! See link. ...

Why does UITableView make so many calls to its delegate & datasource?

Anyone care to shed some light on why UITableView makes so many repeat calls to its delegate & datasource as it's being setup? Just looking at one I'm working on now I see that numberOfSectionsInTableView is called 3 times and then viewForHeaderInSection cycles through 3 more times for each section (I have 2 sections so total of 6 times ...

Whis is the best technical architcture for iPhone App

I am developing an app, which is huge project. I need to create an architecture for the app, so that I can reuse the code for another client.(app will be template I will change UI only) Thinking to apply singleton pattern, but there are some very good design pattern available like MVC, Factory .... Can any one help to find out which is ...

Disclosure "i" button or chevron for iPhone app?

I have a UITableView with rows that each have two actions that can be performed. The user can be shown the item details screen (edit the name and see summary info) or they can 'open' the item to properly interact and play with it. At the moment the first action is achieved via a rounded-rect button with a label "i" in it, and the second ...

How would I save and retrieve a boolean into a file using NSData

I want to save a boolean into a file and also I want to know how you would retrieve it again. I mainly want to use this for when the iPhone terminates and finishes launching in their respected methods. ...

How should I handle a failure in an init: method in Objective-C?

Let's say I'm building a new class for the iPhone in Objective-C. In one of my init methods I want to manually allocate some memory. So, I might have something like this: - (id)initWithSomeObject:(SomeObject *)someObject { self = [super init]; if (self != nil) { myObject = someObject; [myObject retain]; if ( (memory = ...

Using NSPredicate with Core Data for deep relationships

I have an NSArrayController, companiesController bound to a top level Core Data entity, Companies. A Company has many Department's, and a Department has many Employee; these are represented by the 1-to-many relationships, departments and employees. Based on the attribute salary of an Employee I thought I could dynamica...

How to add (id) sender to the following -(IBAction)?

How do you add a (id) sender to the following code? - (IBAction) gobutton: (UIButton *) button5 { Everything I try fails, any help would be appreciated. Thanks. EDIT: I need to keep the (UIButton *) button 5 reference in the (IBAction) ...