Use this tag for questions about design patterns that apply specifically to using the Cocoa and Cocoa-Touch frameworks used in MacOS and iOS development. Examples of such design patterns include, but are not limited to, 'MVC' (model-view-controller), 'delegation', 'observer', 'singleton', 'responder chain', and more. Some of these are well-known patterns but may be used in Cocoa and Cocoa-Touch in more specialised ways.
Questions tagged [cocoa-design-patterns]
174 questions
0
votes
3 answers
Displaying an NSString on a Custom View
I have an interface that has an NSTextField, NSButton, and an NSView. When I type something in the NSTextfield and press the button, I want the text to be drawn in the NSView. So far I have everything connected and working, except for the view.
How…

ilovetacos
- 1
- 2
0
votes
1 answer
When to release the model(representedObject) of the corresponding UIViewController
In AppKit we have "representedObject" available through NSViewController, this representedObject is generally set to ModelController or the model which the NSViewController displays, this works great with bindings as you just set the new…

user313786
- 3
- 1
0
votes
1 answer
Category + lazy instantiation patterns on Objective C
I'm trying to use a lazy instantiation on a category but I'm stuck on how to do that without enter in a obvious infinity loop. Here some code for ilustrate:
@implementation User (Extras)
- (CacheControl *)cache
{
CacheControl *_cache =…

Adriano Spadoni
- 4,540
- 1
- 25
- 25
0
votes
0 answers
How has responsibility to instantiate different view for different models?
In a MVC approach, who is responsible to create a right view for one specific model?
I have two classes C and D both subclass of A. My controller knows how to manage instances of A but it needs to instantiate differents views when objects are…

IgnazioC
- 4,554
- 4
- 33
- 46
0
votes
1 answer
UIPickerView with 2 NSMutableArrays?
I have a core data based app I am working on, that uses an EditingViewController to control a number of different UI elements that get input from the user which describe attributes of an object that is subsequently stored within my app. The…

Steve
- 628
- 1
- 10
- 18
0
votes
2 answers
Pattern for XML Parsing in iPhone
I have a web service which returns certain "models" of which are all defined by a class in objective-c. Calls to RESTful methods will return either a singular model XML or a list of model XML elements.
foo
or
…

jr.
- 4,503
- 7
- 44
- 62
0
votes
3 answers
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.

Jab
- 26,853
- 21
- 75
- 114
0
votes
1 answer
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…

Craig
- 8,093
- 8
- 42
- 74
0
votes
1 answer
Communication between different ViewControllers in Cocoa
I thought that the answer to this question might be very easy to find but in fact it is not. I t is basically about a best practice in MVC but I need a more specific answer to Cocoa's implementation of MVC.
Let's say you have a MainView which…

florianrogner
- 3
- 2
0
votes
1 answer
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;

pramuk
- 41
- 1
- 2
0
votes
3 answers
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…

rson
- 1,455
- 2
- 24
- 43
0
votes
1 answer
How to dynamically scroll NSScrollView based on dragged control
I have an NSScrollView that contains a Drawing. Drawing is a subclass of NSView and is a drop target. I have another class called dragBox which is an NSBox and a drag source. I want to be able to dynamically change the size of the Drawing to…

bc888
- 141
- 14
0
votes
1 answer
view as property of model object alternative
I'm building an arithmetic app & in it there are subclasses of NSObject for Numbers and Digits.Both of these have corresponding view objects which take a Datasource (either number or digit) and a delegate, the view controller.
I have found that it…

chartman
- 132
- 2
- 12
0
votes
1 answer
Communication between multiple MVCs Cocoa
This topic is in my mind for a while. Let's say I have a Cocoa app that requires the user to login. Once the user is logged in, the app will show some data taken from the DB. I have two well designed MVCs (LoginModel, LoginView, LoginController &…

Josue Montano
- 521
- 4
- 16
0
votes
1 answer
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…

gonso
- 2,065
- 5
- 27
- 35