0

我在我的选项卡式 iPhone/iPad 应用程序中使用 BWRSS RSS 提要包装器。我正在使用最新的 Xcode 版本,并且我也提交并接受了两个版本。第一个工作完美,但第二个工作在 iPhone 上,但不是在 iPad 上(虽然它被接受了)。问题似乎源于具有 RSS 提要的选项卡。除了一个 RSS 选项卡外,所有选项卡都可以在应用程序中正常工作。现在,当我在 Ad Hoc 中对其进行测试时,该单个选项卡甚至无法与 iPhone 版本一起使用。(它将与正常的 Building & Running 一起使用。)我曾尝试做快照的事情,但现在那些已经工作不再。我试图改变很多东西来修复它,但似乎没有任何效果。

上个月我试图解决这个问题,但我无法弄清楚。我使用 iPhone 配置实用程序找到了崩溃的根源,这里是:

MBBC[5135] <Error>: *** Terminating app due to uncaught exception         
'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: 
object cannot be nil'
*** First throw call stack:
(0x32a7a2a3 0x3a7a297f 0x329c48d9 0xa1715
0xa46f7 0xa3e59 0x348e9311 0x348f579b 0x348f54c1 
0x348c64e9 0x34885803 0x3462fd8b 0x3462f929 0x3463085d 
0x34630243 0x34630051 0x3488b8eb 0x32a4f6cd 0x32a4d9c1 
0x32a4dd17 0x329c0ebd 0x329c0d49 0x365992eb 0x348d6301 0x9f87f 0x3abd9b20)

我必须使用 iPhone 配置实用程序,因为崩溃只发生在 Ad Hoc 测试中。

这是打开选项卡时应显示的视图控制器的代码。

#import "BWRSSFeedsTableViewController.h"
#import "BWRSSItemsTableViewController.h"
#import "Reachability.h"

@interface BWRSSFeedsTableViewController () {
    BOOL iPadIdiom;
    NSDictionary * _newFeed;
    RSSDB * _rssDB;
    NSArray * _feedIDs;
    BOOL bannerIsVisible;
}
@end

@implementation BWRSSFeedsTableViewController

- (void) viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) iPadIdiom = YES;
    [self loadFeedIDs];
    [self.tableView reloadData];
}

- (void) viewDidAppear:(BOOL)animated {
    if (_newFeed)  [self loadNewFeed];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"RSS Feeds";
    // Do any additional setup after loading the view, typically from a nib.

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

#pragma mark - Segue delegate

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"SegueToItemTableView"]) {
        BWRSSItemsTableViewController * itemsTableViewController = [segue destinationViewController];
        NSIndexPath * path = [self.tableView indexPathForSelectedRow];
        NSNumber * feedID = _feedIDs[path.row];



        itemsTableViewController.currentFeedID = feedID;
        itemsTableViewController.rssDB = _rssDB;
    } 
    else if([segue.identifier isEqualToString:@"SegueToAddView"]) {

        BWRSSAddViewController *rssAddViewController = [segue destinationViewController];
        rssAddViewController.delegate = self;
     }
}

#pragma mark - Table View

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    [self loadFeedIDs];
    return _feedIDs.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FeedsCell" forIndexPath:indexPath];
    [self loadFeedIDsIfEmpty];
    NSDictionary * feedRow = [_rssDB getFeedRow:_feedIDs[indexPath.row]];
    cell.textLabel.text = feedRow[@"title"];
    cell.detailTextLabel.text = feedRow[@"desc"];
    return cell;
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{

    // Return NO if you do not want the specified item to be editable.
    return NO;
}




#pragma mark - Database methods

- (void) loadNewFeed {
    // NSLog(@"%s", __FUNCTION__);
    if (!_newFeed) return;

    NSDictionary * newFeed = _newFeed;
    _newFeed = nil;

    NSNumber * rc = [_rssDB addFeedRow:newFeed];
    NSIndexPath * idx = [self indexPathForDBRec:newFeed];
    if (rc == nil) {    // inserted row in DB
        [self.tableView insertRowsAtIndexPaths:@[idx] withRowAnimation:UITableViewRowAnimationLeft];
    }
    [self.tableView scrollToRowAtIndexPath:idx atScrollPosition:UITableViewScrollPositionNone animated:YES];
    if (rc != nil) {    // updated existing row in DB
        [self.tableView reloadRowsAtIndexPaths:@[idx] withRowAnimation:UITableViewRowAnimationLeft];
    }
}

- (NSIndexPath *) indexPathForDBRec:(NSDictionary *) dbRec {
    NSNumber * rowID = [_rssDB valueFromQuery:@"SELECT id FROM feed WHERE url = ?", dbRec[@"url"]];
    if (rowID) {
        NSArray * tempFeedIDs = [_rssDB getFeedIDs];
        return [NSIndexPath indexPathForRow:[tempFeedIDs indexOfObject:rowID] inSection:0];
    } else {
        return nil;
    }
}

- (NSArray *) loadFeedIDs {
    // NSLog(@"%s", __FUNCTION__);
    if (!_rssDB) [self loadFeedDB];
    _feedIDs = [_rssDB getFeedIDs];
    return _feedIDs;
}

- (NSArray *) loadFeedIDsIfEmpty {
    // NSLog(@"%s", __FUNCTION__);
    if (!_rssDB) [self loadFeedDB];
    if (!_feedIDs || ![_feedIDs count]) _feedIDs = [_rssDB getFeedIDs];
    return _feedIDs;
}

- (RSSDB *) loadFeedDB {
     // NSLog(@"%s", __FUNCTION__);
     // use self.rssDB? or rssDB?
     if (!_rssDB) _rssDB = [[RSSDB alloc] initWithRSSDBFilename:@"bwrss.db"];
    return _rssDB;
}


@end

请告诉我他们是否还有什么我应该补充的,你们可能需要帮助我解决这个非常烦人的问题。谢谢!!!

新 iPhone 配置输出

 MBBC[5750] <Error>: *** Terminating app due to uncaught exception        
'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x32a7a2a3 0x3a7a297f 0x329c48d9 0xe56c5 0xe86fb 0xe7e5b 0x348e9311 0x348f579b     
    0x348f54c1 0x348c64e9 0x34885803 
    0x3462fd8b 0x3462f929 0x3463085d 0x34630243 
    0x34630051 0x3488b8eb 0x32a4f6cd 0x32a4d9c1 0x32a4dd17
    0x329c0ebd 0x329c0d49 0x365992eb 0x348d6301 0xe382f 0x3abd9b20)
    Apr 21 12:36:40 iPhone ReportCrash[5752] <Notice>: Formulating crash report for process MBBC[5750]
    Apr 21 12:36:40 iPhone com.apple.launchd[1] (UIKitApplication:MBBC.App[0x7a64][5750])          
    <Warning>: (UIKitApplication:MBBC.App[0x7a64]) Job appears to have crashed: Abort trap: 6
    Apr 21 12:36:40 iPhone backboardd[26] <Warning>: Application 'UIKitApplication:MBBC.App[0x7a64]' 
    exited abnormally with signal 6: Abort trap: 6
    Apr 21 12:36:40 iPhone ReportCrash[5752] <Error>: libMobileGestalt          
    copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary

我看到它在 6 个东西上崩溃了,但我不知道这到底是什么意思

链接到图片:我不会让我把它上传到这个网站,虽然我之前上传过图片:https ://docs.google.com/file/d/0BxE5vJUTZp7eVWxvRW0wd2pEN2c/edit?usp=sharing

更新:我也尝试从头开始重新启动,只导入文件并检查每个文件,在我导入它们时一个接一个

更新 2:我添加了一个链接到我的故事板的一部分。不让我上传!!!

更新 3:当我添加异常断点时,我更新了它现在给我的内容

4

1 回答 1

1

给你的项目加个异常断点,看看调用链——你肯定会发现问题的。最可能的情况是您创建了一些对象,但始终没有对它的强引用,因此系统在某些情况下会在您想要它之前释放它。一个常见的失败路径是在委托方法中写入 ivar,而不是在块中发布 nil。

于 2013-04-21T13:05:45.613 回答