简体   繁体   中英

TheOS iOS Programmatically UITableview Code Crashes while Scrolling

I use TheOS to develop my jailbreak application. Here is my code of table view programmatically, I almost did the simplest way to implement the table view methods. The table view will show the default table data properly, but the app will crash when I scrolling the table view. my error log didn't show any obvious log. Please help me out, I really can't find out the reason why it will crash immediately while scrolling the view.

#import "DeviceInfoTableViewController.h"

@interface DeviceInfoTableViewController ()

@end

@implementation DeviceInfoTableViewController
{
    NSArray *tableData;
}

- (void)loadView {
    [super loadView];
    self.title = @"Table View Controller";
}

- (void)viewDidLoad {
    [super viewDidLoad];

    // Initialize table data
    tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];
}

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

#pragma mark - Table view data source

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSLog(@"the tableData count: %ld", (unsigned long)tableData.count);
    return tableData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (!cell) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    NSString *str = tableData[indexPath.row];
    cell.textLabel.text = str;
    return cell;
}

#pragma mark - Table view delegate

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

}

@end

I also go to the ips crash report, but it didn't show any useful information.

Error Log:

Oct  3 16:18:51: --- last message repeated 2 times ---
Oct  3 16:18:51 iPhone ReportCrash[3617]: MS:Notice: Injecting: (null) [ReportCrash] (1141.16)
Oct  3 16:18:51 iPhone ReportCrash[3617]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/0MobileGestaltFaker.dylib
Oct  3 16:18:51 iPhone ReportCrash[3617]: MS:Error: binary does not support this cpu type
Oct  3 16:18:51 iPhone ReportCrash[3617]: MS:Error: failure to check GoldPPServer.dylib
Oct  3 16:18:51 iPhone ReportCrash[3617]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/RocketBootstrap.dylib
Oct  3 16:18:51 iPhone ReportCrash[3617]: task_set_exception_ports(B07, 400, F03, 0, 0) failed with error (4: (os/kern) invalid argument)
Oct  3 16:18:51 iPhone ReportCrash[3617]: ReportCrash acting against PID 3614
Oct  3 16:18:51 iPhone ReportCrash[3617]: Formulating crash report for process testproject[3614]
Oct  3 16:18:51 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.zxx.testproject[0x6965][3614]): Service exited due to signal: Segmentation fault: 11
Oct  3 16:18:51 iPhone ReportCrash[3617]: Saved report to /Library/Logs/CrashReporter/testproject_2017-10-03-161851_iPhone.ips
Oct  3 16:18:51 iPhone SpringBoard[3524]: Application 'UIKitApplication:com.zxx.testproject[0x6965]' crashed.
Oct  3 16:18:51 iPhone assertiond[52]: pid_suspend failed for <BKNewProcess: 0x12fe2dfa0; com.zxx.testproject; pid: 3614; hostpid: -1>: Unknown error: -1, Unknown error: -1
Oct  3 16:18:51 iPhone assertiond[52]: Could not set priority of <BKNewProcess: 0x12fe2dfa0; com.zxx.testproject; pid: 3614; hostpid: -1> to 2, priority: No such process
Oct  3 16:18:51 iPhone assertiond[52]: Could not set priority of <BKNewProcess: 0x12fe2dfa0; com.zxx.testproject; pid: 3614; hostpid: -1> to 4096, priority: No such process
Oct  3 16:18:51 iPhone UserEventAgent[44]: id=com.zxx.testproject pid=3614, state=0
Oct  3 16:18:56 iPhone mstreamd[3606]: (Note ) mstreamd: Not monitoring for external power.
Oct  3 16:18:56 iPhone mstreamd[3606]: (Note ) PS: Media stream daemon stopping.
Oct  3 16:18:56 iPhone mstreamd[3606]: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x145e74010>: Shared Streams daemon has shut down.
Oct  3 16:18:56 iPhone mstreamd[3606]: (Warn ) mstreamd: mstreamd shutting down.
Oct  3 16:18:56 iPhone mstreamd[3620]: MS:Notice: Injecting: com.apple.mediastream.mstreamd [mstreamd] (1141.16)
Oct  3 16:18:56 iPhone mstreamd[3620]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/0MobileGestaltFaker.dylib
Oct  3 16:18:56 iPhone mstreamd[3620]: MS:Error: binary does not support this cpu type
Oct  3 16:18:56 iPhone mstreamd[3620]: MS:Error: failure to check GoldPPServer.dylib
Oct  3 16:18:56 iPhone mstreamd[3620]: (Note ) mstreamd: mstreamd starting up.
Oct  3 16:18:56 iPhone mstreamd[3620]: (Note ) PS: Media stream daemon starting...
Oct  3 16:18:57 iPhone locationd[99]: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0

I call this tableView from another Root view controller by this way:

- (void)deviceInfoTap:(id)sender {
    DeviceInfoTableViewController *controller = [[DeviceInfoTableViewController alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
}

Perhaps it happened due to weak reference to your tableData. Assign strong reference for your tableData:

@interface DeviceInfoTableViewController ()

@property (nonatomic, strong) NSArray *tableData;

@end

Then in viewDidLoad:

- (void)viewDidLoad {
    [super viewDidLoad];

    // Initialize table data
    _tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];
}

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