Skip to content

Instantly share code, notes, and snippets.

@infinityrobot
Created August 10, 2012 06:07
Show Gist options
  • Select an option

  • Save infinityrobot/3311622 to your computer and use it in GitHub Desktop.

Select an option

Save infinityrobot/3311622 to your computer and use it in GitHub Desktop.

Revisions

  1. infinityrobot revised this gist Aug 10, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mapViewController.h
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    // I have included a few steps in here to show the flow I normally do to get things working. Keep in mind I'm still a massive noob so there may be a better way to do all of this :/
    // I have included a few steps in here to show the flow I normally do to get things working.
    // Keep in mind I'm still a massive noob so there may be a better way to do all of this :/


    // ...
  2. infinityrobot created this gist Aug 10, 2012.
    34 changes: 34 additions & 0 deletions mapViewController.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    // I have included a few steps in here to show the flow I normally do to get things working. Keep in mind I'm still a massive noob so there may be a better way to do all of this :/


    // ...
    // Class definition and imports

    // STEP 1: Declare vars in the controller @interface
    @interface MapViewController : UIViewController <MKMapViewDelegate, UISearchBarDelegate> {
    // ...

    // Interface objects
    MKMapView *mapView;
    UISearchBar *searchBar;

    // ...

    // Result objects
    NSMutableArray *results;
    NSMutableData *requestData;

    }

    // STEP 2: Declare properties of all above declared vars

    // Interface objects
    @property (nonatomic, retain) MKMapView *mapView;
    @property (nonatomic, retain) UISearchBar *searchBar;

    // Result objects
    @property (nonatomic, retain) NSMutableArray *results;
    @property (nonatomic, retain) NSMutableData *requestData;

    // ...
    // Function definitions etc.
    23 changes: 23 additions & 0 deletions mapViewController.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    // Top of .m
    // ...
    // Imports

    // Implementation
    #pragma mark - MapViewController
    @implementation MapViewController

    // STEP 3: Synthesize the set ivars
    @synthesize mapView, searchBar, results, requestData

    // STEP 4: Now you should be able to use them :)

    // NOTE: If you are using ARC - if you want to allocate a set variable to memory and persist it then do:
    results = [NSMutableArray array]; // from memory?

    // NOTE: If you are not using ARC:
    results = [[NSMutableArray alloc] init]


    // I only ever use @syntesize to connect the .h and .m - as I said I might be wrong but it has worked for me so far haha

    // If anyone else wants to correct me somewhere please do :) I'm keen to learn!