加载空笔尖导致应用商店评论崩溃

Posted

技术标签:

【中文标题】加载空笔尖导致应用商店评论崩溃【英文标题】:Loading empty nib causing crash on appstore review 【发布时间】:2013-06-04 13:09:58 【问题描述】:

Apple 在加载仅包含视图和背景颜色的 nib 时设法让我的应用程序崩溃。我似乎无法在我的设备上遇到崩溃。可能是内存问题还是我在代码中做了一些愚蠢的事情?下面附上报告和代码:

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)

我在视图控制器中使用的代码:

#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

H 文件:

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


@interface ThemesPopOverViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
    NSArray *themes;

@property (nonatomic, retain) UITableView *tableView;





@end

笔尖:

<?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>

【问题讨论】:

【参考方案1】:

我认为您的 ios 部署目标 实用程序->显示文件检查器并取消选中“使用自动布局”选项。

【讨论】:

我怀疑是这种情况,因为错误报告来自 ios 6.1.3 并且布局是空的并且我以编程方式添加所有元素,但是无论如何我都将其关闭,以及其他一些更改到代码。现在它被送回苹果。 More about your hunch【参考方案2】:

在另一台机器上加载项目显示错误,在过程中的某个地方完成了一些重构,只有代码中的 nib 名称没有更新。因此,以某种方式缓存,旧的 nib 被 xcode 使用。然而,在存档中这些笔尖不存在,因此崩溃。我应该尝试清理项目!并仔细查看了代码!

【讨论】:

以上是关于加载空笔尖导致应用商店评论崩溃的主要内容,如果未能解决你的问题,请参考以下文章

如何获取 iOS 应用商店评论页面的 URL

ios 11 的商店服务崩溃

如何从 Play 商店 API 获取数据

使用python爬取App安卓应用商店评论并生成词云

使用python爬取App安卓应用商店评论并生成词云

使用python爬取App安卓应用商店评论并生成词云