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
0
votes
1 answer

What design pattern do I need for a single object which can receive data from different sources?

I'm trying to create some code in Swift that will enable the following functionality. There is a single class (call it the Datastore) that is the main interface into the code - this is what most users of the API will deal with most of the time. This…
Tom H
  • 1,316
  • 14
  • 26
0
votes
2 answers

iOS Design Patterns | Singleton

I am fetching data from server in a method for eg - fetchData(). I want to write logic in such a way that if fetchData() called twice(one after another) from different classes, both classes should be notified once network call is completed. My…
srus2017
  • 394
  • 2
  • 14
0
votes
1 answer

How does KVC in Cocoa check whether an instance variable is accessable?

Recently i was reading "Cocoa Design Patterns". When talking about KVC, it said "KVC check if an accessor named - or -get exists first, if not, it will try instance variable named or _". Can obj-c runtime check whether an…
huoxinbird
  • 520
  • 6
  • 13
0
votes
1 answer

Patterns for Showing a Toast Popup with Custom UITableViewCell

Currently, I have a CustomTableViewCell that is used in four or 5 different places. The custom cell has a lazy loaded UILongPressGestureRecognizer property that gets added as a gesture recognizer in cellForRowAtIndexPath in the parent VC.…
dst3p
  • 1,008
  • 11
  • 25
0
votes
1 answer

addToolTipRect, but where is "modifyToolTipRect"

My view changed sizes, the relative graphical elements i have tooltips for have changed location. Do I really have to remove each tooltip and add again with the new rect? or is there some "modifyToolTipRect" somewhere. I couldn't find one.
JasonGenX
  • 4,952
  • 27
  • 106
  • 198
0
votes
1 answer

Should I check user auth ( user name , password, device token) in webservice every time when my mobile application is launch?

Should I check user auth ( user name , password, device token) in webservice every time when my mobile application is launch? I currently developing an ios application that will need user to login with their username and password ( for the first…
0
votes
2 answers

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),…
Billy Gray
  • 1,747
  • 4
  • 18
  • 23
0
votes
0 answers

In Interface Builder, how do I bind to a property of a class via another class?

OSX desktop ap in Objective-C... I think this is a basic question, but even after spending a good deal of time with the KVO guide and various related questions I can't quite wrap my brain around what's going on in this particular case…
0
votes
1 answer

Is this singleton design pattern bad? Is it wrong to use Singleton in this case?

The problem: For simplicity i'll use a simple example. In a sample application, a Class-A reads some data. Class-A then instantiates Class-B, which then instantiates Class-C. So in all there is a 3-level-hierarchy of classes A --> B --> C Class B…
0
votes
1 answer

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…
jedavis
  • 39
  • 4
0
votes
1 answer

Class design dilemma - duplicated code for fairly close features

I'm building an app that displays objects of a certain type in different view controllers (three or four UITableViewController in this case). In one place they're going to be something like latest objects, in some other place search results and so…
sf89
  • 5,088
  • 7
  • 24
  • 27
0
votes
0 answers

Object creation in swift / two stage object creation in swift

I wonder how allocation and initialization works (On The Hood) in swift. Being a beginner of swift language concepts, I wonder how the object creation works. Does the 2 stage object creation (As in Objective C) is given a bye bye or it is hidden…
riyaz
  • 1,093
  • 1
  • 8
  • 21
0
votes
1 answer

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…
user308405
  • 1,140
  • 8
  • 10
0
votes
2 answers

Cocoa: Implementing the target-action pattern in Objective-C and receiving 'NSInvalidArgumentException unrecognized selector sent to instance'

I'm attempting to implement the target-action pattern in a custom UIControl. Here's the setup: // Inside custom UIControl class - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { ... // UIControl method to…
H K
  • 1,215
  • 2
  • 16
  • 29
0
votes
1 answer

iOS MVC Design Pattern - Layer between REST resource models and view controllers

What do you think about adding a layer with logic between the Models and View Controllers in the MVC pattern? We have models for REST resources that consist of readonly properties and methods for updating/fetching data on server. These models are…