简体   繁体   English

当它在模拟器上而不在iPhone上运行时如何调试?

[英]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. *更新:现在在iPhone或模拟器上均不起作用。 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. 我已经检查了MainWindow.xib文件,没有提到RootViewController。 I renamed this much earlier to CategoryViewController. 我在更早的时候将其重命名为CategoryViewController。

Here is my CategoryViewController at the request of @megger: 这是我在@megger的要求下的CategoryViewController:

#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 . 也许这会有所帮助: 此类不是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". (1)使用诸如BBEdit或EasyFind之类的文本搜索器在项目文件夹中搜索“ 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. 例如,如果您有一个名为RootViewController的类,并使用alloc-init实例化了它,或者以其他无法指定笔尖的方式实例化了它,它将寻找一个名为RootViewController的笔尖。

(2) What was the last time you did a Clean All on this project? (2)您最近一次在此项目上执行“全部清除”吗? 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. 您构建的应用程序中可能存在混乱,只有Clean才能将其删除。 See my advice here: How to Empty Caches and Clean All Targets Xcode 4 在这里查看我的建议: 如何清空缓存并清理所有目标Xcode 4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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