cocoa-design-patterns

Is it worthwhile to implement observer pattern in PHP?

I have been meaning to make use of design pattern in PHP, such as the observer pattern, but that I have to recreate the observers' relationship each time the page is loaded pains me. As references are saved as a new concrete objects in session, there is no way to preserve relationships between subscribers and their observers unless you u...

When to release the model(representedObject) of the corresponding UIViewController.

Hi, 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 representedObject and model details are updated in the view, BUT in case of iPhone (UIKit, with ...

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 textfield 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 can I connect the text and the view so that every time I press the button, the text is dra...

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 specify a single owner class in Interface Builder. Thanks. ...

Which pattern should be used for editing properties with modal view controller on iPhone?

I am looking for a good pattern for performing basic property editing via a modal view on the iPhone. Assume I am putting together an application that works like the Contacts application. The "detail" view controller displays all of the contact's properties in a UITableView. When the UITableView goes into edit mode a disclosure icon i...

Conditional column values in NSTableView?

I have an NSTableView that binds via an NSArrayController to an NSMutableArray. What's in the array are derived classes; the first few columns of the table are bound to properties that exist on the base class. That all works fine. Where I'm running into problem is a column that should only be populated if the row maps to one specific su...

MVC design in Cocoa - are all 3 always necessary? Also: naming conventions, where to put Controller

I'm new to MVC although I've read a lot of papers and information on the web. I know it's somewhat ambiguous and there are many different interpretations of MVC patterns.. but the differences seem somewhat minimal My main question is - are M, V, and C always going to be necessary to be doing this right? I haven't seen anyone address t...

For reopening the autosaved documents the method - (id)initForURL: withContentsOfURL: ofType: error:, gets not call for me

Hi, I have saved my document using autosave functionality at default path (~/Library/Autosave Information/). but while launching the application the autosaved documents are not opening. Even the control does not go this method: - (id)initForURL:(NSURL *)absoluteDocumentURL withContentsOfURL:(NSURL *)absoluteDocumentContentsURL ofType:(...

Core Data, KVO, and NSInternalInconsistencyException

I'm using Core Data and KVO to look for changes in values to trigger saves to the data store. I have a table view with search hooked up to NSFetchedResultsController. When the search changes, a new results controller is made on pressing the Search button. When the user selects an item in the results table view, then the user enters a det...

What is the best way to write a hybrid iPhone app?

I'm developing an iPhone application that will access XML files (or something similar) from a server. I want to convert that data into a slick, native UI on the iPhone. With my current knowledge I could already do this by loading the files, parsing them, writing custom code to fill in data structures and convert the data into user interf...

Can an inherited @property not satisfy a <protocol> @property?

I've got a protocol: @protocol Gadget <NSObject> @property (readonly) UIView *view; - (void) attachViewToParent:(UIView *)parentView; @end And an "abstract" base class, with an implementation (as a getter, not shown) of -(UIView *)view: // Base functionality @interface AbstractGadget : NSObject { UIView *view; } @property (re...

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 bit There are still lots of gaps, and I'm having a hard time finding good readables. Some ...

Recommended document structure. File Wrappers? Roll my own?

Hi, I'm currently working out the best structure for a document I'm trying to create. The document is basically a core data document that uses sqlite as its store, but uses the Apple provided NSPersistentDocument+FileWrapperSupport to enable file wrapper support. The document makes heavy use of media, such as images, videos, audio files...

Getting a unique identifier for each element of NSArrayController's content

I'm making a custom view that I want to be bindings/core data compatible and represent a collection of data (a la NSTableView) Is there any way my view can refer to a specific subset of the elements in the collection (other than the current selection) after a change by the user? A bit of context: The view is going to display a number o...

Why do Cocoa-Touch class ivars have leading underscore character?

Is there some purpose for this convention? ...

How do I persist data managed by NSArrayController without Core Data or NSKeyedArchiver?

I hope you'll excuse the seemingly broad nature of this question, but it gets quite specific. I'm building a document-based Cocoa application that works like most others except that I am using SQLCipher for my data store (a variant of SQLite), because you don't get to set your own persistent data store in Core Data, and also I really ne...

how to draw a pie chart in objective C

Can please somebody help me with the codes for drawing a pie chart for iPad? even documentation on the same would be appreciated. I searched the net but couldn't find anything. ...

How to (elegantly) save View properties with Model properties

I have (or hope to have) a custom view with a bipartite graph in it. Strictly, the model consists of only the labeled nodes and edges. But the user can move the nodes around to better visualize some aspect currently under study. When re-opening the document the XY locations of each node should remain the same as when it was last saved...

Nib file (and code) organization in a one-window, non-document-based app

Good people of StackOverflow, I am in the early stages of building a non-document-based Cocoa application. What I'm aiming for is a window layout similar to iTunes, with a left, middle, and right pane. The Xcode template for such an application includes a file called MainMenu.xib containing both the main menu, and the main application w...

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 being fine for, eg. an RSS reader, for some applications it seems far from ideal. In my case,...