Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7044725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:26:38+00:00 2026-05-28T02:26:38+00:00

When my view is trying to load, the applications crashes and i get this

  • 0

When my view is trying to load, the applications crashes and i get this stack:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'

This is my code, i don’t really know where to look when this crash is occurred:

#import "Itineraire.h"
#import "SBMapView.h"
#import "SBRouteAnnotation.h"
#import "City.h"
#import "UICGRoutes.h"
#import "SBCheckPointViewController.h"
//#import "SBRouteDetailView.h"

@interface Itineraire(Private)
-(void)customInitialization;
@end

@implementation Itineraire(Private)

-(void)customInitialization
{
    // do the initialization of class variables here..

    mDirections          = [UICGDirections sharedDirections];
    mDirections.delegate = self;
}

@end

@implementation Itineraire

@synthesize map             = mMap;
@synthesize startPoint      = mStartPoint;
@synthesize endPoint        = mEndPoint;
@synthesize loadBtn     = mLoadBtn;
@synthesize annotationArray = mAnnotationArray;
@synthesize travelMode      = mTravelMode;
@synthesize destination;
@synthesize routes;
@synthesize mAnnotations;
@synthesize mRouteArray;
@synthesize mRouteDetail;

//Invoked when the class is instantiated in XIB
-(id)initWithCoder:(NSCoder*)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if( self)
    {
        [self customInitialization];
    }
    return self;
}

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        [self customInitialization];
    }
    return self;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Google Maps";
    self.map = [[SBMapView alloc] initWithFrame:CGRectMake(0, 49, self.view.frame.size.width, self.view.frame.size.height)];
    //self.map = [[SBMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 381)];

    [self.view addSubview:mMap];

    self.view.backgroundColor = [UIColor blackColor];
    self.annotationArray = [[NSMutableArray alloc]init];
    self.routes          = [[UICGRoutes alloc]init];


    if (mDirections.isInitialized) {
        [self updateRoute];
    }
}
/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];

}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:YES];

}
- (void)viewWillDisappear:(BOOL)animated; 
{
    [super viewWillDisappear:YES];

}

#pragma mark -
#pragma mark Instance Methods

- (void)updateRoute
{   /*
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
     UICGDirectionsOptions *options = [[[UICGDirectionsOptions alloc] init] autorelease];
     options.travelMode = mTravelMode;
     City *mFirstCity = [[[City alloc]init] autorelease];
     mFirstCity.mCityName = @"Paris";//mStartPoint;
     //[mDirections loadWithStartPoint:mFirstCity.mCityName endPoint:destination options:options];
     //added
     NSMutableArray * DestinationCityArray = [[NSMutableArray alloc]init];
     [DestinationCityArray addObject:@"Berlin"];
     [mDirections loadWithStartPoint:mFirstCity.mCityName endPoint:destination options:options];
     */
    //
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    UICGDirectionsOptions *options = [[UICGDirectionsOptions alloc] init] ;
    options.travelMode = mTravelMode;
    City *mFirstCity = [[City alloc]init];
    mFirstCity.mCityName = @"Amsterdam";//mStartPoint;
    NSMutableArray *dest=[[NSMutableArray alloc]init];
    [dest addObject:@"Berlin"];
    [mDirections loadWithStartPoint:mFirstCity.mCityName endPoint:dest options:options];


}

-(void)loadRouteAnnotations
{
    self.mRouteArray = [mDirections routeArray];
    NSLog(@"mRouteArray %@",mRouteArray);
    self.mAnnotations = [[NSMutableArray alloc]init];
    for (int idx = 0; idx < [mRouteArray count]; idx++) {
        NSArray *_routeWayPoints1 = [[mRouteArray objectAtIndex:idx] wayPoints];
        NSArray *mPlacetitles = [[mRouteArray objectAtIndex:idx] mPlaceTitle]; 
        self.annotationArray = [NSMutableArray arrayWithCapacity:[_routeWayPoints1 count]-2];

        mLoadBtn.title = @"OFF";
        mLoadBtn.target = self;
        mLoadBtn.action = @selector(removeRouteAnnotations);

        for(int idx = 0; idx < [_routeWayPoints1 count]-1; idx++)
        {

            mBetweenAnnotation = [[SBRouteAnnotation alloc] initWithCoordinate:[[_routeWayPoints1 objectAtIndex:idx]coordinate]
                                                                          title:[mPlacetitles objectAtIndex:idx]
                                                                 annotationType:SBRouteAnnotationTypeWayPoint];
            [self.annotationArray addObject:mBetweenAnnotation];
        }
        [mAnnotations addObject:mAnnotationArray];
        [self.map.mapView addAnnotations:[mAnnotations objectAtIndex:idx]];
        NSLog(@"map %@",mMap);

    }   
}

-(void)showCheckpoints
{
    SBCheckPointViewController *_Controller = [[SBCheckPointViewController alloc]initWithNibName:@"SBCheckPoints" bundle:nil];
    [self.navigationController pushViewController:_Controller animated:YES];
    NSMutableArray *arr = [[mDirections checkPoint] mPlaceTitle];
    _Controller.mCheckPoints = arr ;


}



//
-(void)removeRouteAnnotations
{
    NSMutableArray *mTempAnnotation;// = [mAnnotations retain];
    for (int idx = 0; idx < [mTempAnnotation count]; idx++) {
        [mMap.mapView removeAnnotations:[mTempAnnotation objectAtIndex:idx] ];
    }   
    mLoadBtn.title = @"ON";
    mLoadBtn.target = self;
    mLoadBtn.action = @selector(loadRouteAnnotations);
}


#pragma mark <UICGDirectionsDelegate> Methods

- (void)directionsDidFinishInitialize:(UICGDirections *)directions {
    [self updateRoute];
}

- (void)directions:(UICGDirections *)directions didFailInitializeWithError:(NSError *)error {
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Map Directions" message:[error localizedFailureReason] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
    [alertView show];
}

- (void)directionsDidUpdateDirections:(UICGDirections *)indirections {
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

    UICGPolyline *polyline = [indirections polyline];
    NSArray *routePoints = [polyline routePoints];

    [mMap loadRoutes:routePoints]; // Loads route by getting the array of all coordinates in the route.

    UIToolbar *tools = [[UIToolbar alloc]
                        initWithFrame:CGRectMake(0.0f, 0.0f, 103.0f, 44.01f)]; // 44.01 shifts it up 1px for some reason
    tools.clearsContextBeforeDrawing = NO;
    tools.clipsToBounds = NO;
    tools.tintColor = [UIColor colorWithWhite:0.305f alpha:0.0f]; // closest I could get by eye to black, translucent style.
    // anyone know how to get it perfect?
    tools.barStyle = -1; // clear background
    NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2];

    // Create a standard Load button.

    self.loadBtn = [[UIBarButtonItem alloc]initWithTitle:@"ON" 
                                                   style:UIBarButtonItemStyleBordered 
                                                  target:self 
                                                  action:@selector(loadRouteAnnotations)];

    [buttons addObject:mLoadBtn];

    // Add Go button.
    UIBarButtonItem *mGoBtn = [[UIBarButtonItem alloc] initWithTitle:@"Go" 
                                                               style:UIBarButtonItemStyleBordered 
                                                              target:self 
                                                              action:@selector(showCheckpoints)];
    [buttons addObject:mGoBtn];

    // Add buttons to toolbar and toolbar to nav bar.
    [tools setItems:buttons animated:NO];
    UIBarButtonItem *twoButtons = [[UIBarButtonItem alloc] initWithCustomView:tools];
    self.navigationItem.rightBarButtonItem = twoButtons;

    //Add annotations of different colors based on initial and final places.
    SBRouteAnnotation *startAnnotation = [[SBRouteAnnotation alloc] initWithCoordinate:[[routePoints objectAtIndex:0] coordinate]
                                                                                  title:mStartPoint
                                                                         annotationType:SBRouteAnnotationTypeStart];
    SBRouteAnnotation *endAnnotation = [[SBRouteAnnotation alloc] initWithCoordinate:[[routePoints lastObject] coordinate]
                                                                                title:mEndPoint
                                                                       annotationType:SBRouteAnnotationTypeEnd];


    [mMap.mapView addAnnotations:[NSArray arrayWithObjects:startAnnotation, endAnnotation,nil]];
}

- (void)directions:(UICGDirections *)directions didFailWithMessage:(NSString *)message {
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Map Directions" message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
    [alertView show];
}

#pragma mark -

@end

I tried to put my code on a new project (empty application) and it worked fine, i didn’t understand that error and its possible causes.

EDIT:

I tried to track the problem by elimination,and my code worked fine when i remove this method:

//Invoked when the class is instantiated in XIB

-(id)initWithCoder:(NSCoder*)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if( self)
    {
        [self customInitialization];
    }
    return self;
}

However, when i run, my app doesn’t display me the route between the two points (The purpose of the app). So this method seems important for the whole class because without it, i couldn’t get the route and in the other side when it’s there, the app crashes. How should i deal with this contradiction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:26:38+00:00Added an answer on May 28, 2026 at 2:26 am

    @Vince is putting you on the right track. Since the problem is in an NSURL method being called by a framework (Google Maps in this case) you need to debug what you are passing to the framework. You have the source for the framework also right? You can set breakpoints in loadWithStartPoint:endPoint:options:] to see what’s going on.

    One thing I did notice is you are passing an NSMutableArray as the endPoint param when I believe it expects an NSString.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load a new view into an existing view controller, but I
I am trying to load a new view with the following code - (void)tableView:(UITableView
I am trying to load json generated by my django app. It works when
I am using the Goole app engine datastore with Java and trying to load
So I'm trying to load a simple URL (http://www.google.com) into a web view. I
I'm trying to load a view specific stylesheet in an asp.net mvc3 application (just
I have a view based application. I am trying to load a second custom
I'm trying to use SimplePie with Codeigniter but I can't get even the view
I have a folder structure like this and I'm trying to load the News
is there any way to send whats in a text view (im trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.