0

2015-07-13 23:56:13.659 ICBuses[41867:12770881] -[__NSArrayI intValue]: unrecognized selector sent to instance 0x7fddc8e00e30 2015-07-13 23:56:13.670 ICBuses[41867:12770881] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI intValue]: unrecognized selector sent to instance 0x7fddc8e00e30' * First throw call stack:

He's the data I am parsing into a class then from there I am using the data to put the GPS location of a bus on my map. I don't believe I'm calling intvalue on an array. I am separating the data into NSStrings then instantiating my class for busGPS. Then on the instance of the class I'm calling intValue on that property of the class. Please help and thank you. He is the data for the bus location: ( { heading = "-4"; id = 110; lat = "41.66044"; lng = "-91.53468"; }

I need the lat and lng in int form to use with google map api. Here is my code. This is my model object Header:

@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

the interface:

#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

He is the header of my 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

Heres the implementation file

#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
Paulw11
  • 108,386
  • 14
  • 159
  • 186

0 Answers0