简体   繁体   中英

How to debug when it works on simulator but not on iPhone?

*Update: This now doesn't work on either the iPhone or the Simulator. After I ran a clean build I got the error on the simulator:

Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/572536B3-5E7D-4F2B-8D80-4345412DCF10/Quotes.app> (loaded)' with name 'RootViewController'

I have inspected the MainWindow.xib file and there is no mention of the RootViewController. I renamed this much earlier to CategoryViewController.

Here is my CategoryViewController at the request of @megger:

#import <UIKit/UIKit.h>
#import "Category.h"
#import "AddSubjectController.h"
#import "SubjectViewController.h"
#import "SBTableAlert.h"

@class SubjectViewController;
@class AddSubjectController;
@class SearchViewController;

@interface CategoryViewController : UITableViewController  <UIAlertViewDelegate, SBTableAlertDelegate, SBTableAlertDataSource> {

    NSMutableArray *categories;
    NSMutableArray *allCategories;
    NSMutableArray *subjects;
    NSMutableArray *allSubjects;
    AddSubjectController *addSubController;
    SubjectViewController *subViewController;
    SearchViewController *svc;
    NSIndexPath* checkedIndexPath;

}

@property (nonatomic, retain) NSMutableArray *categories;
@property (nonatomic, retain) NSMutableArray *allCategories;
@property (nonatomic, retain) Subject *selectedSubject;
@property (nonatomic, retain) Quote *selectedQuote;
@property (nonatomic, retain) NSMutableArray *allSubjects;
@property (nonatomic, retain) NSMutableArray *subjects;
@property (nonatomic,assign) QuoteMapViewController *qmv;
@property (nonatomic,assign) SearchViewController *svc;
@property (nonatomic, assign) NSInteger mySection;
@property (nonatomic, assign) NSInteger myRow;
@property (nonatomic, retain) NSIndexPath* checkedIndexPath;

@end

Another stack poster had a similar issue.

Perhaps this will be of assistance: this class is not key value coding-complient for the key .

I'm not quite sure what you are looking for, are you trying to make it to where you can run certain code in the simulator itself and not on the actual device? If this is what you are looking for, the way I approached this was by defining a macro that allows you to wrap your code inside parentheses and only runs it in the simulator.

#define SIM(x) if ([[[UIDevice currentDevice].model lowercaseString] rangeOfString:@"simulator"].location != NSNotFound){x;}

You can take away the semicolon at the end if you would like to add it within the parentheses, but it might seem weird adding a semicolon between parentheses.

This code is used like this:

SIM(NSLog(@"This is only logged within the simulator."))
Could not load NIB in bundle: 
'NSBundle </var/mobile/Applications/572536B3-5E7D-4F2B-8D80-4345412DCF10/Quotes.app> 
(loaded)' with name 'RootViewController'

(1) Use a text searcher like BBEdit or EasyFind to search your project folder for "RootViewController". It's there somewhere. For example, if you have a class called RootViewController and you instantiate it with alloc-init or in some other way that fails to specify a nib, it will look for a nib called RootViewController.

(2) What was the last time you did a Clean All on this project? I think it's time to do one. There may be cruft in your built app, and only a Clean can get it out of there. See my advice here: How to Empty Caches and Clean All Targets Xcode 4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM