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
2
votes
2 answers
iphone global settings - best way to implement it?
I'd like to have some settings that I can access from anywhere in my app. Is there a best way to implement this? Right now I'm just sticking properties in my app delegate, then access them with:
ClientAppDelegate *appDelegate = (ClientAppDelegate…

WoodenKitty
- 6,521
- 8
- 53
- 73
2
votes
3 answers
Why not enforce strict singleton application delegate object to use in NIBs?
I just ran myself round in circles, all coming down to having instantiated an app delegate object in a secondary NIB that wasn't the NSMainNibFile. Amazing how having two app delegates kicking around means you have separate…

stevesliva
- 5,351
- 1
- 16
- 39
2
votes
3 answers
Objective C - Problem with objectForKey
Okay, I'm trying to write a high score function for my app.
My problem is that when no high score has been saved yet, my program crashes.
If I save it with:
[[NSUserDefaults standardUserDefaults] setObject:@"[given string]"…

Pat
- 21
- 2
2
votes
3 answers
iOS delegate and Singleton pattern
I am developing an iOS application. My used design pattern Singleton and Delegation patterns. I did nil a delegate object in dealloc method. If user re opened this screen and set to delegate object self. But I see delegate object always nil. How…

hiwordls
- 781
- 7
- 17
- 35
2
votes
3 answers
how to create multiple pages in Xcode iphone apps
i am starting my experience with iphone sdk. and i have a question, which is i am trying to create two pages to the app but i don't know how to link them or design them. like when i start the Xcode i find one page named View to design in it, i want…

user256467
- 21
- 1
- 1
- 2
2
votes
4 answers
How to tell if an object has already been allocated, so it isn't allocated multiple times?
Please be nice.. I am a noob with this stuff. I want to allocate and use an object through a method that I call many times, and instead of making it a global variable and allocating it in my initWithFrame method I want to alloc it in just the one…

Jab
- 26,853
- 21
- 75
- 114
2
votes
5 answers
confusion over Objective-c views, delegates, and outlets
I am trying to teach myself objective-c, but coming from a Python/Java background, it is proving very difficult. I tried to post a bunch of points I am confused on, but it was marked as too vague, so I'll break it into sections.
First, every example…

AH16
- 337
- 1
- 2
- 13
2
votes
0 answers
Cocoa Idiomatic First Responder and Keyboard Event Handling Design
I've been reading the Cocoa Event Handling Guide to understand how to handle keyboard events for my application. However, I'm not quite sure if the solution I've found is the idiomatic way to approach this problem or even the best.
I have a view…

John Drake
- 183
- 1
- 8
2
votes
1 answer
cocoa-touch dependency injection and loading code dynamically
I'm looking into porting an existing enterprise app to iPad. One of the key requirements is that there is a basic functioning app that needs to be highly customizable/extensible. Also, the people working on the customizations and extensions are not…

sfeher
- 117
- 3
- 10
2
votes
1 answer
best practices for archiving/unarchiving NSTableViewController data?
I have an NSWindowViewController that owns a nib file. One of the objects in the nib file is an NSTableView, managed by an NSTableViewController (also part of nib).
I want to implement the NSCoding protocol to save off all model data, some of which…

wrjohns
- 484
- 4
- 14
1
vote
1 answer
Separation of concerns for an iOS MVC application
I'm particularly interested in how to follow Apple's standards with respect to a good MVC pattern design. Let me illustrate my question with an example.
Lets say I have a number of fairly complicated UI elements on screen such as UITableView.…

EightyEight
- 3,430
- 4
- 36
- 67
1
vote
2 answers
Best pattern for handling touches in an animated UIView/CALayer?
I have a UIView instance that I am animating using CAKeyframeAnimation. It is a looping animation and will be constantly in motion. However, I need to allow user interaction with the item (responding to taps, to be exact). Because CoreAnimation…

Wayne Hartman
- 18,369
- 7
- 84
- 116
1
vote
1 answer
How to use tabbar in mac Application
i am trying to develop mac application(cocoa app).i have successfully used tabbar in iphone app. but in developing mac application ,how to use tabbar?
As we use tabbar for iphone application,i want to implement same kind of functionality for Mac…

kushalrshah
- 638
- 1
- 5
- 14
1
vote
1 answer
Does adding a NSObject into MainMenu.xib creates a singleton object?
Let say I have a NSObject AppController:NSObject. Using IB, I drag an NSObject control into MainMenu.xib and points the class to AppController. Since MainMenu.xib is loaded once and objects inside MainMenu.xib are in memory for the life of the app,…

jemeshsu
- 1,784
- 16
- 14
1
vote
2 answers
Is there a standard, documented, development pattern to create UI layouts similar to iTunes, iCal, iPhoto, etc?
I am new to Cocoa development and I am trying to create UI layouts using what I consider to be the "standard" layout that is shared by apps like iTunes, iCal, iPhoto, Billings, 1Password, Numbers, Delicious Library, etcetera. This typical layout can…

Christian Correa
- 245
- 3
- 14