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
3
votes
3 answers
What is the correct system design when dealing with third party API?
This blog post by Joubert just opened my eyes. I have dealt with a lot of design patterns in Java and other languages. But Objective-C is a rather unique language.
Let's say that in a project we talk with a third party API, like Dropbox or Facebook.…

Enrico Susatyo
- 19,372
- 18
- 95
- 156
3
votes
1 answer
Is it OK for other threads to have indirect access to a managed object context running in a thread of its own?
Apple's recommended method for multithreading core data is to use a managed object context per thread, and to send changes from one context to another by saving the changed thread's context to a shared persistent store.
While I can imagine that…

Chris Devereux
- 5,453
- 1
- 26
- 32
3
votes
2 answers
Why Cocoa design patterns not representing best practices on Apple documentation anymore?
I just would like to know why from the official documentation of Apple, the common cocoa design patterns used doesn't represent the best practices to develop apps.
From…

santibernaldo
- 825
- 1
- 11
- 26
3
votes
0 answers
Share object instance between scenes in an mac os x cocoa storyboard
In an appkit storyboard targeting mac os x 10.10+.
Is there a way to have InterfaceBuilder instantiate a custom model object and then have InterfaceBuilder inject the instance in to multiple view controllers as IBOutlets?
I can only get it to work…

weenzeel
- 797
- 5
- 17
3
votes
1 answer
Best Practices for Using Reactive Cocoa to update server data via REST API
There are plenty of resources on the web regarding the use of Reactive Cocoa for the purpose of "pulling" data from the web via API, etc.
I like the MVVM approach, and am trying to figure out what a good practice would be for sending updates via…

Michael Bopp
- 656
- 1
- 4
- 13
3
votes
2 answers
Reuse nib's across multiple UIViewControllers
I've created some custom UITableViewCells in a nib file and would like to use that across multiple UIViewControllers.
Can anyone tell me the best practice way to do that? My limited knowledge around loading nibs seems to suggest that you have to…

colm
- 45
- 1
- 4
3
votes
1 answer
How to reduce memory footprint when instantiating a hierarchy of model objects in Cocoa?
I'm writing a quiz application for iPhone using basic NSObject subclasses to represent the models. At runtime the various controllers instantiate the model classes and populate them with data read in from a plist on the disk.
The model classes…

prairiedogg
- 6,323
- 8
- 44
- 52
3
votes
4 answers
Is this a good (Cocoa-like, Apple-approved) model class?
I've been using Objective-C for a while, but I've not been following Apple's guidelines very well. Recently I read Cocoa Design Patterns and the Model Object Implementation Guide, and I'm trying to do some very simple things, but do them very…

andyvn22
- 14,696
- 1
- 52
- 74
3
votes
2 answers
MVC in a Cocoa document-based application
I'm going through a refactoring and reorganization of my application at the moment. I've realized that some of the separation between models and views, and their controllers has diminished and I wish to do some cleaning up.
I have several key…

CJ.
- 1,034
- 1
- 9
- 20
3
votes
1 answer
OSX: Get application windows + bounds
Is there a way to get the list of windows from another application and their bounds. E.g. using F-Script or obj-c or any other way (except AppleScript) to access the window contents of another (any other) Cocoa-based application and possibly modify…

ktolis
- 443
- 1
- 3
- 14
3
votes
1 answer
Managing multiple UICollectionViewLayouts within a single UICollectionViewController
Apologies if this is a duplicate, but I couldn't find anything on an initial search. And I'm struggling to get my head around the design.
I am attempting to create some interactive transitions between UICollectionViewLayouts using the new iOS7 APIs…

Tim
- 8,932
- 4
- 43
- 64
3
votes
1 answer
Core Data and Private Frameworks
SO, I have an application with several NSManagedObject classes, and I'd like to extract some of the logic and put it into a self-contained framework, to be used in other applications.
I have a class like, let's say:
Employee
- firstName …

iluvcapra
- 9,436
- 2
- 30
- 32
3
votes
1 answer
custom Location Manager class using CLLocationManager
I'm pretty new to iOS development (my first app) and I faced this issue.
I have an iPhone app that should get user's current location in multiple ViewControllers upon user button touch. To prevent redundant code (implementing…

NarbehM
- 345
- 2
- 13
3
votes
5 answers
Abstract class in Objective-C
I need your help. Following problem in Objective-C:
// Robot.h
@protocol RobotProtocol
-(void)doWork;
@end
@interface Robot : NSObject
// Rob1 sublass of class Robot
// rob1.h
@interface Rob1 : Robot
//…

Michael Dorner
- 17,587
- 13
- 87
- 117
3
votes
1 answer
Objective-C: instance pointer with protocol
Normally when developer makes a pointer to the instance of class which implements a protocol, she does this:
id myInstance = [[SomeClass alloc] init];
Is it OK to be more specific about the instance's class type and use it like…

valdyr
- 198
- 1
- 10