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
1
vote
1 answer
synchronize one object between two controllers in Cocoa
I have a MainController, it creates an object(say polygon), a controller(say,polygonViewController). PolygonViewController has two outlets:
IBOutlet Polygon* aPolygon;
IBOutlet UILabel* numOfSidesLabel;
it mediates Polygon and…

Michael Z
- 4,534
- 4
- 21
- 27
1
vote
1 answer
Problem with multiple window/NIB cocoa application
I'm having a problem with my Cocoa app. I'm using my app delegate as a controller, and opening one window in a NIB file. Clicking a toolbar button opens another window from another NIB. Clicking save on this second window calls a method on the…

Shawn
- 717
- 11
- 31
1
vote
1 answer
Initialize static NSString at class level
I have a NSString that should be constant in my class. I used the following code to accomplish this:
@interface DefinitionViewController ()
@end
static NSString *preamble;
@implementation DefinitionViewController {
}
+(void)initialize {
if…

Bill
- 1,588
- 12
- 21
1
vote
3 answers
Segmented Controller (Multiple Choices) with Core Data
I have a Core Data based application which is built around one main entity. There are several other entities which are connected to it, one of which is an Entity called "Notes".
This Notes entity has a Date (NSDate), a Description (NSString), and…

Mark Leonard
- 2,056
- 19
- 28
1
vote
3 answers
Whis is the best technical architcture for iPhone app?
I am developing an app, which is a 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…

iPhoneDev
- 2,995
- 4
- 33
- 44
1
vote
2 answers
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…

JOM
- 8,139
- 6
- 78
- 111
1
vote
3 answers
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.
-…

rson
- 1,455
- 2
- 24
- 43
1
vote
4 answers
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
@interface Thing : NSManagedObject
{
}
@property (nonatomic, retain)…

gerry3
- 21,420
- 9
- 66
- 74
1
vote
2 answers
draggingEntered not called
I have an NSBox subclass called dragBox. I want to be able to drag it around a canvas. The code is as follows:
-(void) awakeFromNib
{
[[self superview] registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
}
-(void)…

bc888
- 141
- 14
1
vote
0 answers
Implementing Document-based Applications with CoreAnimation Layers
I am working on a diagram drawing application that is based on CoreAnimation framework. I have a common functionality set that includes: creating diagram objects, editing their geometrical properties, moving them around, etc. Each object is…

Rizo
- 3,003
- 5
- 34
- 49
1
vote
1 answer
Frustrating Pattern in Objective C
Apple recommends NOT to use property methods in initializers, however I'm unsure of the protocol to follow if you need to call a method from an initializer that also needs to be called from else where in the program after the object is initialized.…

Ser Pounce
- 14,196
- 18
- 84
- 169
1
vote
0 answers
Elegant pattern for long running operations in GCD and reporting errors to user?
I'm looking to clean up some code I have that has gotten out of control. There are often situations where I need to interact with a couple of remote APIs, such as Parse and Facebook, perhaps Core Data, while the user is waiting, staring at my…

Alexandr Kurilin
- 7,685
- 6
- 48
- 76
1
vote
2 answers
Asynchronous Requests/Responses: When am I really done?
This is a design pattern question.
Imagine a programming task where one is developing a client that will interact with a server asynchronously (via streams). Let's say the challenge is to execute an indeterminate number of tasks, each of which may…

xyzzycoder
- 1,831
- 13
- 19
1
vote
0 answers
Database sync on three different platforms
I currently have a web based application using cherryPy, PostgreSQL & SQLalchemy. I've been using it for years but am looking at developing an iOS app with a database on the device for locations with poor or no wireless net connection.
On the iPhone…

adamek
- 2,324
- 3
- 24
- 38
1
vote
1 answer
Cocoa: How to dynamically size the NSTextField?
I created a label:
NSTextField *label = [NSTextField alloc] initWithFrame:NSMakeRect(50, 50, 100, 50)];
[txtField setStringValue:inputString];
[txtField setEditable:false];
The length of inputString is unknown at compile time, so how can I…

ObjectiveC-InLearning
- 443
- 1
- 7
- 20