2015-07-13 23:56:13.659 ICBuses [41867:12770881] - [__ NSArrayI intValue]:无法识别的选择器发送到实例0x7fddc8e00e30 2015-07-13 23:56:13.670 ICBuses [41867:12770881] *由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:' - [__ NSArrayI intValue]:无法识别的选择器已发送例如0x7fddc8e00e30' * 首先抛出调用堆栈:
他将数据解析为一个类,然后从那里我使用数据将公交车的GPS位置放在我的地图上。我不相信我在数组上调用intvalue。我将数据分成NSStrings然后实例化我的busGPS类。然后在类I的实例上,在类的属性上调用intValue。请帮助,谢谢。他是巴士位置的数据:( { heading =" -4&#34 ;; id = 110; lat =" 41.66044&#34 ;; lng =" -91.53468&#34 ;; }
我需要int形式的lat和lng与google map api一起使用。这是我的代码。 这是我的模型对象 部首:
@interface BusLocation : NSObject
@property (strong, nonatomic) NSString *lat;
@property (strong, nonatomic) NSString *lng;
@property (weak, nonatomic) NSString *heading;
- (instancetype) initWithLat:(NSString *)lat lng:(NSString *)lng heading:(NSString *)heading;
@end
界面:
#import "BusLocation.h"
@implementation BusLocation
- (instancetype) initWithLat:(NSString *)lat lng:(NSString *)lng heading:(NSString *)heading {
self = [super init];
if (self) {
_lat = lat;
_lng = lng;
_heading = heading;
}
return self;
}
@end
他是我的mapView的标题
#import <UIKit/UIKit.h>
#import "MapViewController.h"
#import "API.h"
@class BusLocation;
@interface MapViewController : UIViewController
@property (strong, nonatomic) NSString *routeAgency;
@property (strong, nonatomic) NSString *route;
@property (strong, nonatomic) NSArray *busLocation;
@property (strong, nonatomic) NSArray *routeInfo;
@property (strong, nonatomic) NSString *testLat;
@property int testLatInt;
@property int testLngInt;
@property (strong, nonatomic) NSString *testLng;
@property (strong, nonatomic) BusLocation *busGPS;
@end
继承实施文件
#import "MapViewController.h"
@import GoogleMaps;
#import "BusLocation.h"
@interface MapViewController ()
@end
@implementation MapViewController {
GMSMapView *busRouteMapview_;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"Name: %@, Agency: %@", self.route, self.routeAgency);
self.routeInfo = [[API sharedAPI] routeInfoAgency:self.routeAgency
Route:self.route];
self.busLocation = [[API sharedAPI] busLocation:self.routeAgency
Route:self.route];
NSLog(@"Bus Location: %@", self.busLocation);
//Setup class to use with Google Map
NSString *testlat = [self.busLocation valueForKey:@"lat"];
NSString *testlng = [self.busLocation valueForKey:@"lng"];
NSString *testheading = [self.busLocation valueForKey:@"heading"];
self.busGPS = [[BusLocation alloc] initWithLat:testlat lng:testlng heading:testheading];
int testing = [self.busGPS.lat intValue];
// Create a GMSCameraPosition that tells the map to display the
// cooridante
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:41.4444
longitude:-91
zoom:12];
busRouteMapview_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
busRouteMapview_.myLocationEnabled = YES;
self.view = busRouteMapview_;
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end