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

  • SEARCH
  • Home
  • 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 1080633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:03:45+00:00 2026-05-16T22:03:45+00:00

My app runs fine in the simulator, but when running on the device, it

  • 0

My app runs fine in the simulator, but when running on the device, it terminates with SIGABRT. I have narrowed it down to the following code:

- (void)loadImage {
int imageNumber = currentImageNumber;
// check to see if the image has already been downloaded.
// if not, get it and add it to an array
if ([imageData count] < totalNumberOfImages && (imageNumber + 1) > [imageData count]) {
    NSString *urlString = [[mainMenuItem.imageDetails objectAtIndex: imageNumber] objectForKey: @"url"];
    NSURL *url = [NSURL URLWithString: urlString];
    NSData *data = [NSData dataWithContentsOfURL: url];
    UIImage *image = [UIImage imageWithData: data];
    [imageData addObject: image];
}

// set the image from the array
self.imageOnScreen = [imageData objectAtIndex: imageNumber];

}

It is the [imageData addObject:image]; message that generates the crash, with the following console output:

2010-09-17 00:03:03.005 PilotsMate[17426:5e03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x313f4fd3 __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x3302f8a5 objc_exception_throw + 24
    2   CoreFoundation                      0x31377f99 -[__NSArrayM insertObject:atIndex:] + 472
    3   CoreFoundation                      0x31377da7 -[__NSArrayM addObject:] + 34
    4   PilotsMate                          0x00007c5d -[WeatherDetailViewController loadImage] + 300
    5   PilotsMate                          0x00007eb1 -[WeatherDetailViewController displayPicture:] + 232
    6   Foundation                          0x33265c9d -[NSThread main] + 44
    7   Foundation                          0x332ea9e1 __NSThread__main__ + 972
    8   libSystem.B.dylib                   0x3527598d _pthread_start + 248
    9   libSystem.B.dylib                   0x3526b0ec thread_assign_default + 4294967295
)
terminate called after throwing an instance of 'NSException'
[Switching to thread 11523]
[Switching to thread 11523]
Program received signal:  “SIGABRT”.
kill

What is causing this, since there are no issues in the simulator? I’m very puzzled and would appreciate your input. All I am doing is initialising an NSMutableArray in viewDidLoad and then adding an object to the array. If I clean the targets, there is no change to what happens. Weird, because this part of the app ran fine a few days ago and I’ve not modified this implementation file at all (nor have I updated to the newest iOS 4.1 yet, so there is no change to the OS or Xcode version either).

  • 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-16T22:03:46+00:00Added an answer on May 16, 2026 at 10:03 pm

    The error message you pasted says it all:

    [NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 0
    

    The image object is nil. Why is it nil? Set a breakpoint in Xcode while running it in the Simulator and figure out which line above it in the culprit.

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

Sidebar

Related Questions

My app runs just fine in the simulator, but now I have a developers
i have developed an app that runs perfectly fine on the simulator but when
my app runs on iPhone device and also in simulator. Everythings seems fine, but
I have some code which runs fine in simulator, but when I try to
I have an iPhone app that compiles and runs fine in the Simulator on
We have a WinForms app that runs fine on x86, but has many third-party
I have a scroll view app which runs fine on the simulator, however, when
My app is running fine in Simulator as well as device. Now I am
I have an interesting problem. My app runs fine on the iphone 4.2 simulator,
My GAE app runs fine from my computer, but when I upload it, I

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.