我正在对具有MKMapView的ViewController进行一些单元测试。
如果我想测试mapview是不是nil,我必须显式初始化它,否则只需使用mapview就不需要了。
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface HomeVC : UIViewController <UIImagePickerControllerDelegate, CLLocationManagerDelegate, MKMapViewDelegate> {
MKMapView* mapView;
CLLocationManager* locationManager;
CLLocationCoordinate2D currentLocation;
}
@property (nonatomic, strong) IBOutlet MKMapView* mapView;
@property(nonatomic, strong)CLLocationManager* locationManager;
@property(nonatomic)CLLocationCoordinate2D currentLocation;
@end
@implementation HomeVC
@synthesize mapView, cameraButton,cameraView, locationManager, currentLocation;
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView = MKMapView.new;
self.mapView.mapType = MKMapTypeStandard;
}
如果我在地图初始化后放置一个断点,它会显示仅使用UIView属性初始化的mapView。它在我的Storyboard文件中正确连接。并且工作正常,我无法测试它上面的任何属性。