Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Is my code outline above (the beginnings of) a decent MVC implementation?</p> </blockquote> <p>By my standards, yes</p> <blockquote> <p>how do I get the Model to update the Controller </p> </blockquote> <p>You are correct, you want to use a delegate. You declare the delegate protocol along with the class it is a delegate for. So expanding on your <code>MarkersModel</code> header:</p> <pre><code>@protocol MarkersModelDelegate&lt;NSObject&gt; -(void) markersDidUpdate:(MarkersModel*)model; @end @interface MarkersModel : NSObject { __weak id&lt;MarkersModelDelegate&gt; delegate; } @property(weak,nonatomic) id&lt;MarkersModelDelegate&gt; delegate; </code></pre> <p>Then in your view controller:</p> <pre><code>@interface MapViewController : UIViewController&lt;MKMapViewDelegate, MarkersModelDelegate&gt; { </code></pre> <p>Then in the model implementation:</p> <pre><code>@implementation MarkersModel @synthesize delegate; //... -(void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects { // Thanks to Restkit data is an array of Marker classes data = objects; // Pass data to controller if( delegate != nil ) { [delegate markersDidUpdate:self]; } } </code></pre> <blockquote> <p>Will I create any dangling pointers - I suspect something should be unsafe_unretained (I am compiling to 4.3)?</p> </blockquote> <p>Not that I am aware of</p> <blockquote> <p>Is my MarkersModel declaration in the controller class correct? I am concerned that it will not be managed by ARC. I also suspect it is public but should be private.</p> </blockquote> <p>You can declare it as private by adding the <code>@private</code> header beforehand:</p> <pre><code>@interface MapViewController... { @private MarkersModel *markersModel; ... </code></pre> <blockquote> <p>Should the MarkersModel.getMarkers method be static?</p> </blockquote> <p>If by static, you mean as a class-level instead of instance-level method, that entirely depends on your implementation. If all <code>MarkersModel</code> objects are supposed to retain the same data, then yes it makes sense to make it class-level. But if each <code>MarkersModel</code> object is supposed to retain its own set of <code>Markers</code> then no, it should remain an instance-level method</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload