Search code examples
iphoneiosnsexceptioncgrectmake

Getting an exception from CGRectMake when running on iOS device (but not simulator)


I have an exception happening that I just can't figure out. I have this bit of code here:

newControllers = [[NSMutableArray alloc] initWithCapacity:9];  // Only allocate what we need


    // Ok, add the new thumb UIs
    for (int i = 0; i < 3; ++i) {

        for (int j = 0; j < 3; ++j) {

            // Create the view controller
            ThumbViewController *newThumbVC = [[ThumbViewController alloc]
                                                   initWithNibName:@"NewThumbDisplayView" bundle:nil];
            // Set the info
            newThumbVC.localInfo = [newInfo objectAtIndex:(i * 3) + j];

            // Place it properly
            [self.scrollViewContent addSubview:newThumbVC.view];
            CGRect rect = CGRectMake(8 + (j * 99), 363 + (i * 134), 106, 142);
            newThumbVC.view.frame = rect;
            [self.scrollViewContent bringSubviewToFront:newThumbVC.view];

            [newControllers addObject:newThumbVC];
        }
    }

When running on the simulator, this works just perfectly. This morning I tried to run it on my phone, and I get an exception when calling CGRectMake with the following stack (Note that nothing is printed out in the output window at all making this more of a pain to figure out).

Thread 1, Queue : com.apple.main-thread

    #0  0x35220238 in objc_exception_throw ()
    #1  0x3751b788 in +[NSException raise:format:arguments:] ()

If anybody can point out to me what exactly is not right here, I would be very grateful.


Solution

  • This turned out to be a problem with a version mismatch between my iOS version on my device and the version of XCode I was running. Updating XCode took care of everything.