iPhone : Simple UITableViewController crash withou

2019-09-09 13:13发布

I'm trying to build a simple TableView program struture. It seems to work fine, but if I scroll the list to high or to low, the app crashes without any console error and the trace into the debugger does not help.

You can see it by yourself looking at the project I put at : http://shine.free.fr/tmp/myTestApp.zip

Can you help me :

  • to know what goes wrong
  • to know how I may find what goes wrong without having to ask each time. Usually I check my connection, lokk for compile errors, look into the console and try to debug, but there, nothing helps me.

Thank you for your help

1条回答
Melony?
2楼-- · 2019-09-09 13:43

The problem is that your ListController object is not retained when it is loaded from nib file, so it is not guaranteed that it will be valid after nib is loaded (and in fact it is not). To solve your problem add an outlet for ListController property and define retaining property for it. Here's FenetreListeController.h that fixes your problem:

#import <UIKit/UIKit.h>

@class ListeController;

@interface FenetreListeController : UIViewController {
    IBOutlet ListeController* listController;
}

@property (nonatomic, retain) ListeController* listController;
@end

You will also need to set outlet connection in IB and synthesize property in .m file

For more information about how objects are loaded from xib files check "The Nib Object Life Cycle" section from "Resource Programming Guide"

查看更多
登录 后发表回答