4

Hi I'm very new to ios development.

I'm developing a map application where I use mapkit. I have a viewController with the map view and a corresponding viewController class.

Now I would like to manipulate the mapView, and is trying to set up the delegate. BUT i can't ctrl+drag anything (includes the mapView) to my header-file. So what do I do then??

I've tried to write the auto implemented stuff in my header-file but this isn't working either :(

Any help is really appreciated..

Here's my header-file:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

#define METERS_PER_MILE 1609.344

@interface MapViewController : UIViewController<MKMapViewDelegate> {

}

@property (weak, nonatomic) IBOutlet MKMapView *mapView;

@end

And a note to ios developers what the hell is this drag and drop doing in a IDE?!?

DNRN
  • 2,397
  • 4
  • 30
  • 48
  • Which XCode version? Also to answer your second question (what the hell is this drag and drop doing in a IDE): Makes your life simpler by generating stubs and setting outlets to nil upon deallocation (if needed) :) – Alladinian May 07 '12 at 14:02
  • I'm using xcode 4.2. Is there some documentations on the drag and drop issue, what's happens behind the scenes and such, tried to search a bit around without luck :( – DNRN May 07 '12 at 14:04

2 Answers2

8

Here are the steps to create an IBOutlet in XCode:

  1. Click on your xib / Storyboard to edit it in Interface Builder
  2. Bring the view for which you want to create an outlet in front
  3. Make sure that Assistant editor is visible. If not click on this icon: enter image description here
  4. Now you should see your source file next to your UI editor (also make sure that you've set the custom class of your controller in the identity inspector)
  5. Important: Make sure that your editor is not zoomed out. Click on the = button to do so.
  6. Set the assistant mode to 'Automatic' if you don't see your header file and control+drag to your source to create the IBOutlet enter image description here

I hope that this will clarify the whole procedure for you. Note that this is only a convenience. You could manually declare the IBOutlet and connect it to your view as well.

Alladinian
  • 34,483
  • 6
  • 89
  • 91
  • 3
    Thanks for the explicit answare! My problem was I hadn't sat the ViewController class in the Identity Inspector, after this the "Automatic" worked :) – DNRN May 08 '12 at 07:08
0

Make sure that the assistant type is set to counterparts enter image description here sometimes xcode will automatically set this to manual and you will be trying to drag to a header that had nothing to do with your xib

Jason McTaggart
  • 878
  • 1
  • 7
  • 18