views:

40

answers:

0

Hi, I've a problem with MKMapView.

The Problem is that when I ran the app without referencing the MKMapView to the File's owner it works, but when I reference the MKMapView to the File's owner and I ran the app it crashes, and I don't know why.

This is the view I'm using:

View

And this is the code I have:

InfoController.h

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

@interface InfoController : UIViewController <MKMapViewDelegate> {
    MKMapView *mapView;
}

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

@end

InfoController.m

#import <MapKit/MapKit.h>
#import "InfoController.h"

@implementation InfoController

@synthesize mapView;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    /*MKCoordinateSpan span;
    span.latitudeDelta=1.1;
    span.longitudeDelta=1.1;

    CLLocationCoordinate2D location;
    location.latitude = 45.000;
    location.longitude = 12.000;

    MKCoordinateRegion region;
    region.span = span;
    region.center= location;
    [mapView setRegion:region];*/
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];    
}

- (void)viewDidUnload {
    [super viewDidUnload];
}


- (void)dealloc {
    [super dealloc];
}

@end

Thanks for any help :)

EDIT:

Error in console:

Attaching to process 7332.
2010-10-07 12:28:53.782 PrimosBar[7332:207] ******* Accessibility Status Changed: On
2010-10-07 12:28:53.972 PrimosBar[7332:207] ********** Loading AX for: com.yourcompany.PrimosBar ************
2010-10-07 12:28:55.935 PrimosBar[7332:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6b9fe10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mapView.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x024f2919 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x026405de objc_exception_throw + 47
    2   CoreFoundation                      0x024f2851 -[NSException raise] + 17
    3   Foundation                          0x0002dc2b _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x0002db99 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x004a7d0a -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x02468b6f -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x004a6721 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x004a84b5 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x0035ffbb -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x0035dcd1 -[UIViewController loadView] + 120
    11  UIKit                               0x0035dbab -[UIViewController view] + 56
    12  UIKit                               0x0036fd53 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
    13  UIKit                               0x0036e8c7 -[UITabBarController transitionFromViewController:toViewController:] + 64
    14  UIKit                               0x003706a1 -[UITabBarController _setSelectedViewController:] + 263
    15  UIKit                               0x00370510 -[UITabBarController _tabBarItemClicked:] + 352
    16  UIKit                               0x002b5e14 -[UIApplication sendAction:to:from:forEvent:] + 119
    17  UIKit                               0x004ae1bc -[UITabBar _sendAction:withEvent:] + 422
    18  UIKit                               0x002b5e14 -[UIApplication sendAction:to:from:forEvent:] + 119
    19  UIKit                               0x0033f6c8 -[UIControl sendAction:to:forEvent:] + 67
    20  UIKit                               0x00341b4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    21  UIKit                               0x0033f67f -[UIControl sendActionsForControlEvents:] + 49
    22  UIKit                               0x002b5e14 -[UIApplication sendAction:to:from:forEvent:] + 119
    23  UIKit                               0x0033f6c8 -[UIControl sendAction:to:forEvent:] + 67
    24  UIKit                               0x00341b4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    25  UIKit                               0x003406f7 -[UIControl touchesEnded:withEvent:] + 458
    26  UIKit                               0x002d92ff -[UIWindow _sendTouchesForEvent:] + 567
    27  UIKit                               0x002bb1ec -[UIApplication sendEvent:] + 447
    28  UIKit                               0x002bfac4 _UIApplicationHandleEvent + 7495
    29  GraphicsServices                    0x02d58afa PurpleEventCallback + 1578
    30  CoreFoundation                      0x024d3dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    31  CoreFoundation                      0x02434737 __CFRunLoopDoSource1 + 215
    32  CoreFoundation                      0x024319c3 __CFRunLoopRun + 979
    33  CoreFoundation                      0x02431280 CFRunLoopRunSpecific + 208
    34  CoreFoundation                      0x024311a1 CFRunLoopRunInMode + 97
    35  GraphicsServices                    0x02d572c8 GSEventRunModal + 217
    36  GraphicsServices                    0x02d5738d GSEventRun + 115
    37  UIKit                               0x002c3b58 UIApplicationMain + 1160
    38  PrimosBar                           0x00001f3c main + 102
    39  PrimosBar                           0x00001ecd start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.

EDIT 2

The error was due to the use of TabBar: http://stackoverflow.com/questions/1578239/mkmapview-nsunknowkeyexception