0

Apple manages to get my app crash while loading a nib that only contains a view and a background color. I can't seem to get the crash on my device. Could it be a memory issue or am i doing something silly in the code? The report and code is attached below:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x32b0629e __exceptionPreprocess + 158
1   libobjc.A.dylib                 0x3a9aa97a objc_exception_throw + 26
2   CoreFoundation                  0x32b061c0 +[NSException raise:format:] + 100
3   UIKit                           0x34aab56c -[UINib instantiateWithOwner:options:] + 1632
4   UIKit                           0x34aaab96 -[UIViewController _loadViewFromNibNamed:bundle:] + 230
5   UIKit                           0x349a3038 -[UIViewController loadView] + 88
6   UIKit                           0x3492d468 -[UIViewController loadViewIfRequired] + 64
7   CodeFriend                      0x000b3b14 -[ThemesPopOverViewController initWithNibName:bundle:] (ThemesPopOverViewController.m:24)
8   CodeFriend                      0x000b221a -[AppDelegate settingAct:] (AppDelegate.m:127)

The code i use in the viewcontroller:

#import "ThemesPopOverViewController.h"

@interface ThemesPopOverViewController ()

@end

@implementation ThemesPopOverViewController
@synthesize tableView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {


        themes = [[NSArray alloc] initWithObjects:kRegexHighlightViewThemeArray];
        self.tableView = nil;
        self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(20, 0, self.view.frame.size.width - 40, 350)];
        [self.tableView setBackgroundColor:[UIColor clearColor]];
        [self.tableView setDelegate:self];
        [self.tableView setDataSource:self];
        [self.view addSubview:self.tableView];
        int item = [themes indexOfObject:theDelegate.codeView.currentTheme];
        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:0];
        [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];

    }

    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;    //count of section
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //NSLog(@"%d",themes.count);
    return [themes  count];    //count number of row from counting array hear cataGorry is An Array
}



- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *MyIdentifier = @"MyIdentifier";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:MyIdentifier];

        UIView *bgColorView = [[UIView alloc] init];
        [bgColorView setBackgroundColor:[UIColor colorWithRed:25/255.0f green:185/255.0f blue:152/255.0f alpha:1.0f]];
        [cell setSelectedBackgroundView:bgColorView];
    }
    [cell.textLabel setFont:[UIFont fontWithName:@"Helvetica" size:16]];
    cell.textLabel.text = [themes objectAtIndex: indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%d", indexPath.row);
    [theDelegate.codeView setHighlightThemeFromString:[themes objectAtIndex:indexPath.row]];
    [theDelegate removePop];

}

@end

The H file:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"


@interface ThemesPopOverViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>{
    NSArray *themes;
}
@property (nonatomic, retain) UITableView *tableView;





@end

The nib:

<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
    <data>
        <int key="IBDocument.SystemTarget">1552</int>
        <string key="IBDocument.SystemVersion">12D78</string>
        <string key="IBDocument.InterfaceBuilderVersion">3084</string>
        <string key="IBDocument.AppKitVersion">1187.37</string>
        <string key="IBDocument.HIToolboxVersion">626.00</string>
        <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
            <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
            <string key="NS.object.0">2083</string>
        </object>
        <array key="IBDocument.IntegratedClassDependencies">
            <string>IBProxyObject</string>
            <string>IBUIView</string>
        </array>
        <array key="IBDocument.PluginDependencies">
            <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
        </array>
        <object class="NSMutableDictionary" key="IBDocument.Metadata">
            <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
            <integer value="1" key="NS.object.0"/>
        </object>
        <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
            <object class="IBProxyObject" id="372490531">
                <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
            <object class="IBProxyObject" id="975951072">
                <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
            <object class="IBUIView" id="191373211">
                <reference key="NSNextResponder"/>
                <int key="NSvFlags">274</int>
                <string key="NSFrame">{{0, 20}, {128, 214}}</string>
                <reference key="NSSuperview"/>
                <object class="NSColor" key="IBUIBackgroundColor">
                    <int key="NSColorSpace">2</int>
                    <bytes key="NSRGB">MC4yNTg4MjM1NDM4IDAuMzYwNzg0MzIyIDAuNDI3NDUxMDE0NQA</bytes>
                </object>
                <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
                <object class="IBUISimulatedSizeMetrics" key="IBUISimulatedDestinationMetrics">
                    <string key="IBUISimulatedSizeMetricsClass">IBUISimulatedFreeformSizeMetricsSentinel</string>
                    <string key="IBUIDisplayName">Freeform</string>
                </object>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
        </array>
        <object class="IBObjectContainer" key="IBDocument.Objects">
            <array class="NSMutableArray" key="connectionRecords">
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchOutletConnection" key="connection">
                        <string key="label">view</string>
                        <reference key="source" ref="372490531"/>
                        <reference key="destination" ref="191373211"/>
                    </object>
                    <int key="connectionID">3</int>
                </object>
            </array>
            <object class="IBMutableOrderedSet" key="objectRecords">
                <array key="orderedObjects">
                    <object class="IBObjectRecord">
                        <int key="objectID">0</int>
                        <array key="object" id="0"/>
                        <reference key="children" ref="1000"/>
                        <nil key="parent"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">1</int>
                        <reference key="object" ref="191373211"/>
                        <reference key="parent" ref="0"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">-1</int>
                        <reference key="object" ref="372490531"/>
                        <reference key="parent" ref="0"/>
                        <string key="objectName">File's Owner</string>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">-2</int>
                        <reference key="object" ref="975951072"/>
                        <reference key="parent" ref="0"/>
                    </object>
                </array>
            </object>
            <dictionary class="NSMutableDictionary" key="flattenedProperties">
                <string key="-1.CustomClassName">ThemesPopOverViewController</string>
                <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="-2.CustomClassName">UIResponder</string>
                <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
            </dictionary>
            <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
            <nil key="activeLocalization"/>
            <dictionary class="NSMutableDictionary" key="localizations"/>
            <nil key="sourceID"/>
            <int key="maxID">3</int>
        </object>
        <object class="IBClassDescriber" key="IBDocument.Classes"/>
        <int key="IBDocument.localizationMode">0</int>
        <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
        <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
        <int key="IBDocument.defaultPropertyAccessControl">3</int>
        <bool key="IBDocument.UseAutolayout">YES</bool>
        <string key="IBCocoaTouchPluginVersion">2083</string>
    </data>
</archive>
David Karlsson
  • 9,396
  • 9
  • 58
  • 103

2 Answers2

1

I think what you have iOS deployment target < 6.0 and you don't turn off autolayout. Go to View->Utilites->Show File Inspector and uncheck "Use Autolayout" option.

enter image description here

ZGl6YXNt
  • 1,814
  • 18
  • 17
  • I doubt this is the case, since the error report is from ios 6.1.3 and since the layout is empty and i add all elements programatically, however i turned it off anyways, that and some other changes to the code. Now it is sent back to apple. [More about your hunch](http://stackoverflow.com/questions/11198981/presentviewcontroller-crash-on-ios-6-autolayout) – David Karlsson Jun 09 '13 at 14:07
0

Loading the project on another machine showed the errors, somewhere along the process some refactoring was done, only the nib names in code were not updated. Therefore, somehow cached, old nibs were used by xcode. In the archive however these nibs were not present, therefore the crash. I should have tried to clean the project! and looked over the code more!

David Karlsson
  • 9,396
  • 9
  • 58
  • 103