Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 正在获取-[\uu NSArrayI integerValue]异常_Ios_Nsarray_Nsexception - Fatal编程技术网

Ios 正在获取-[\uu NSArrayI integerValue]异常

Ios 正在获取-[\uu NSArrayI integerValue]异常,ios,nsarray,nsexception,Ios,Nsarray,Nsexception,2015-07-13 23:56:13.659 ICBus[41867:12770881]-[\uu NSArrayI intValue]:发送到实例0x7fddc8e00e30的无法识别的选择器 2015-07-13 23:56:13.670 ICBus[41867:12770881]*由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\uu NSArrayI intValue]:未识别的选择器发送到实例0x7fddc8e00e30' *第一次

2015-07-13 23:56:13.659 ICBus[41867:12770881]-[\uu NSArrayI intValue]:发送到实例0x7fddc8e00e30的无法识别的选择器 2015-07-13 23:56:13.670 ICBus[41867:12770881]*由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\uu NSArrayI intValue]:未识别的选择器发送到实例0x7fddc8e00e30' *第一次抛出调用堆栈:

他是我解析到一个类中的数据,然后从那里我使用这些数据在我的地图上显示一辆公共汽车的GPS位置。我不相信我在数组上调用intvalue。我将数据分离为NSString,然后为busGPS实例化我的类。然后在类的实例上,我对该类的属性调用intValue。请帮忙,谢谢你。他提供了公交车位置的数据: { 标题=-4; id=110; lat=41.66044; 液化天然气=-91.53468; }

我需要的lat和液化天然气在int格式使用谷歌地图api。这是我的密码。 这是我的模型对象 标题:

界面:

#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
他是我地图视图的标题

#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

用完整准确的错误更新您的问题。添加一个异常断点以标识异常发生的行。此外,获取纬度的intValue没有多大意义-纬度是十进制数。请显示NSLog@Bus位置:%@,self.busLocation;
#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