ゾンビが原因で iPhone アプリがクラッシュするか、メモリ リークが発生しています。コードを 3 行に絞り込み、コードをコメント化/コメント解除することで、2 つのうちの 1 つを確実に発生させることができます。バグは、結果のリスト (tableView) とマップといくつかのラベルを含む詳細ページの間のナビゲーションで発生し、マップから結果のリストに戻る最初のナビゲーションでメモリ リークが発生し、おそらく 5/ 6 回別の結果に移動して戻る。
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#define METERS_PER_MILE 1609.344
@interface ResDetailsPageVC : UIViewController <MKMapViewDelegate, UIAlertViewDelegate> {
UISegmentedControl *mapTypeSwitcher;
MKMapView *mapView;
UILabel *nameLabel;
UIButton *addressLabel;
UILabel *telephoneLabel;
NSString *address;
}
@property (nonatomic, retain) IBOutlet UISegmentedControl *mapTypeSwitcher;
@property (nonatomic, retain) IBOutlet MKMapView *mapView;
@property (nonatomic, retain) IBOutlet UILabel *nameLabel;
@property (nonatomic, retain) IBOutlet UIButton *addressLabel;
@property (nonatomic, retain) IBOutlet UILabel *telephoneLabel;
- (IBAction)segmentedControlIndexChanged;
- (IBAction)callButtonClick;
- (IBAction)addressClick;
- (void) callNumber;
@end
@synthesize mapView;
@synthesize mapTypeSwitcher;
@synthesize nameLabel, addressLabel, telephoneLabel;
- (void)dealloc {
// if these lines are commented out - memory leak
// if not - zombie?!
/*self.telephoneLabel = nil;
self.addressLabel = nil;
self.nameLabel = nil;*/
self.mapView = nil;
self.mapTypeSwitcher = nil;
[super dealloc];
}