Questions tagged [cocoa-design-patterns]

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.

174 questions
7
votes
4 answers

Bad-practice to retain 'self'?

I have a simple query that I'd like cleared up by someone... Is it bad-practice to retain self? I have a server request object that I'd like to make. I'd like to be able to use it in the following fashion: ARequest *request = [ARequest request:…
Tricky
  • 7,025
  • 5
  • 33
  • 43
6
votes
3 answers

Notification Center in C++

After programming for sometime with the iOS and Mac objective C frameworks, I have come to love the generic notification pattern implemented by the NSNotificationCenter and NSNotification classes. Coming back to C++, which has always been my…
6
votes
4 answers

Collecting data from multiple ViewControllers in Swift

I'm having multiple viewcontrollers (in a navigation stack or maybe not) and each controllers collects some data based on users input. In the end I need to use those data in the last controller. So what would be the best approach/design-pattern to…
Vineet Ravi
  • 1,457
  • 2
  • 12
  • 26
6
votes
1 answer

Java Command Pattern vs iPhone Delegate Pattern

Hi I am a java developer and these days I have also started working on iphone development. I was wondering that Java's command pattern is somewhat similar to delegate pattern in iphone or vice-versa because in both there is somebody else doing work…
Mann
  • 2,118
  • 1
  • 18
  • 18
6
votes
2 answers

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

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…
Héctor Ramos
  • 9,239
  • 6
  • 36
  • 39
6
votes
6 answers

Core Data pattern: how to efficiently update local info with changes from network?

I have some inefficiency in my app that I'd like to understand and fix. My algorithm is: fetch object collection from network for each object: if (corresponding locally stored object not found): -- A create object if (a nested related…
Jaanus
  • 17,688
  • 15
  • 65
  • 110
6
votes
3 answers

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…
Jim
  • 890
  • 2
  • 10
  • 22
5
votes
4 answers

Singleton with a delegate: Good idea or bad?

I have created objects that are interfaces to a web service. One typical object would be a "TaskService". When a client uses one of these objects, it invokes one of the service's methods (such as "GetTasks") and the service will asynchronously go…
dark_perfect
  • 1,458
  • 1
  • 23
  • 41
5
votes
1 answer

Advice for a Cocoa drawing application

I'm new to Cocoa and looking for a little advice for an application from experienced Cocoa-ers.  I'm building a basic OmniGraffle-style app where objects are drawn/dragged onto a canvas. After the objects are on the canvas, they can be selected to…
mrflibble
  • 101
  • 1
  • 2
5
votes
1 answer

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…
user52138
  • 61
  • 1
  • 3
5
votes
2 answers

Cocoa Application Bootstrap Questions

I am an experienced developer, new to Mac development, so I Read a nice objective C guide Read the Apple memory management guide Went through the Apple intro to Cocoa Checked out the NSApplication and NSApplicationDelegate Refs Messed around a…
kelf
  • 472
  • 4
  • 9
5
votes
3 answers

UIButton - should we release or not?

I want to add a button on a view dynamically. Here is the code. UIButton *x=[UIButton buttonWithType:UIButtonTypeRoundedRect]; Here, I have not used "alloc" function. The questions for this statements are as follow. If we are using imageview for…
4
votes
1 answer

High-Level App Design/Architecture

I've done a fair amount of iOS development in the past couple of years, so I'm pretty familiar with iOS architecture and app design (everything's a ViewController that you either push, pop, or stick into tab bars). I've recently started exploring…
4
votes
2 answers

Avoiding coupling in a document-based Cocoa app?

I'm new to Mac programming and I'm working on a document-based application. My NSDocument subclass creates a NSWindowController subclass. This window controller creates two NSViewController subclasses as well. Sometimes, a change in one of the views…
msoler
  • 2,930
  • 2
  • 18
  • 30
4
votes
4 answers

Why do some objects not need to be initialized before use in objective-c?

Why do some objects not need to be initialized before use in objective-c? For example why is this NSDate *today = [NSDate date]; legal?
lampShade
  • 4,361
  • 8
  • 34
  • 50
1
2
3
11 12