Crash working with UITableView

Hi, I have the following code:

public abstract class MoeTestViewController extends UITableViewController {
   ....
    UITableView tableView = UITableView.alloc().init();
    setTableView(tableView);
    tableView.registerClassForCellReuseIdentifier(
        org.moe.natj.objc.Class.fromJavaClass(MyTableViewCell.class), "MyTableViewCell");
}

and the class

and the crash looks like:

As a workaround I use UITableView instead of MyTableViewCell, crash disappear.

Can you please review this class:

thanks

There is an RssReader example showing a custom table view cell. I was able to make my own based on that example. https://github.com/multi-os-engine/moe-samples-java/tree/master/RssReader

I saw this sample, my problem is with UITableViewCell, not with UITableViewController itself. UITableViewController working, but MyTableViewCell not.

Dear Kirill Prazdnikov,

according to you crashlog, the problem was -[UITableView UTF8String]: unrecognized selector sent to instance. UTF8String is a method of NSString. This means somewhere you are passing a UITableView to a method which expects an NSString. Due to the nature of how Objective-C works and how NatJ binds it to Java, is it not impossible for this to happen without any warnings.
The cause of this can be a few things:

  • Forced casting via NatJ
  • Incorrect bindings

Can you share your tableViewCellForRowAtIndexPath method with us? Looking at your stacktrace, I think the issue might originate from there.

Best Regards,
Kristóf

Here it is, please review

Dear Kirill Prazdnikov,

the classes seem ok. A Java stacktrace might be helpful. Try wrapping different parts of your code in try-catch. If you don’t know where to wrap, try with UIApplicationMain.

    public static void main(String[] args) {
        try {
            UIKit.UIApplicationMain(0, null, null, Main.class.getName());
        } catch (Throwable t) {
            t.printStackTrace(System.err);
        }
    }

Best Regards,
Kristóf