无法使用仪器 - XCode 8找到对象的强引用

时间:2016-11-11 07:18:19

标签: ios xcode8 instruments popviewcontroller strong-references

假设我有根视图控制器A.然后我推视图控制器B.但是在弹出B之后,它没有被释放(使用dealloc方法检查,没有调用popViewController。如果我错了请纠正我)。我已经做了很多搜索,并得出结论,最可能的原因是“对视图控制器保持对象的强引用”。

我尝试使用仪器的分配工具,使用可用的教程找出为什么我的视图控制器在popViewController之后没有被释放,或者是否有对象的强引用。

以下是我在乐器中得到的结果:

enter image description here

如上面的屏幕截图所示,显示的行数是我没有得到的。

我的问题是:

  1. 如何检测导致视图控制器在popViewController

  2. 之后不释放的原因
  3. 如果对第一个问题的回答是“对该视图控制器持有的对象的强引用”。究竟是什么以及如何检测它?

  4. 更新:

    以下是从登录屏幕导航到仪表板的代码

    LoginVC.h

    #import <UIKit/UIKit.h>
    #import "UIPaddingLabel.h"
    ..
    .
    .
    @interface LoginVC : UIViewController
    {
    .
    .
    @property (weak) UIPaddingLabel *errorLbl;
    .
    .
    .
    
    @end
    

    LoginVC.m

        #import "LoginVC.h"
        #import "Dashboard.h"
        .
        .
    
        @interface LoginVC ()<UITextFieldDelegate, UIAlertViewDelegate>
        {
            CALayer *layer1, *layer2;
    
            UIAlertAction *actionToEnable;
    
            ANGModal *mod;
    
            UILabel *errMark1, *errMark2;
    
            UITextField *forgotTF;
    
            NSString *encodedString;
    
            UIImageView *backImgV;
            UIView *overlay;
    
            BOOL shouldAnimate;
    
            NSOperationQueue *operationQueue;
    
    
        }
        @end
    
        @implementation LoginVC
    
        .
        .
    
        //if login successful
    
        Dashboard *dashObj = [[Dashboard alloc] initWithNibName:@"Dashboard" bundle:nil];
        self.navigationController pushViewController:dashObj animated:YES];
    
        .
    .
    .
        -(void)dealloc
        {
            NSLog(@"Released... %s", __PRETTY_FUNCTION__);
        }
    
        @end
    

    Dashboard.h

    #import <UIKit/UIKit.h>
    #import "UIPaddingLabel.h"
    
    @interface Dashboard : UIViewController
    
    @property (weak, nonatomic) IBOutlet UILabel *alertCountLbl;
    
    @property (weak, nonatomic) IBOutlet UICollectionView *scheduleCV;
    @property (weak, nonatomic) IBOutlet UICollectionView *courseCV;
    
    @property (weak, nonatomic) IBOutlet UIButton *menuBtn;
    @property (weak, nonatomic) IBOutlet UIButton *nextScheduleBtn;
    
    @property (weak, nonatomic) IBOutlet UIActivityIndicatorView *spinner;
    
    //iphone only
    @property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
    @property (weak, nonatomic) IBOutlet UIView *containerView;
    
    @property (weak, nonatomic) IBOutlet UIImageView *sliderImageV;
    
    @property (weak, nonatomic) IBOutlet UILabel *performCountLbl;
    @property (weak, nonatomic) IBOutlet UIButton *performanceBtn;
    @property (weak, nonatomic) IBOutlet UIButton *myBagBtn;
    @property (weak, nonatomic) IBOutlet UIButton *storeBtn;
    @property (weak, nonatomic) IBOutlet UIButton *groupsBtn;
    
    @property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgSliderTopAlign;
    
    //ipad only
    @property (weak, nonatomic) IBOutlet UILabel *headTitle;
    
    @property (weak, nonatomic) IBOutlet UILabel *monthYearLbl;
    @property (weak, nonatomic) IBOutlet UIButton *calBtn;
    @property (weak, nonatomic) IBOutlet UICollectionView *calendarCV;
    
    @property (weak, nonatomic) IBOutlet UIView *scheduleV;
    @property (weak, nonatomic) IBOutlet UIButton *classBtn;
    @property (weak, nonatomic) IBOutlet UIButton *homeBtn;
    @property (weak, nonatomic) IBOutlet UIButton *todayBtn;
    @property (weak, nonatomic) IBOutlet UIButton *plannedBtn;
    @property (weak, nonatomic) IBOutlet UIButton *completedBtn;
    @property (weak, nonatomic) IBOutlet UICollectionView *otherCV;
    
    @property (weak, nonatomic) IBOutlet UILabel *onlineMarker;
    @property (weak, nonatomic) IBOutlet UIButton *bottomBanner;
    @property (weak, nonatomic) IBOutlet UIPaddingLabel *myCourseTitle;
    @property (weak, nonatomic) IBOutlet UIButton *sdCardBtn;
    
    @property (weak, nonatomic) IBOutlet NSLayoutConstraint *scheduleBarLeftSpace;
    @property (weak, nonatomic) IBOutlet NSLayoutConstraint *calendarWd;
    @property (weak, nonatomic) IBOutlet NSLayoutConstraint *otherCVBottomSpace;
    @property (weak, nonatomic) IBOutlet NSLayoutConstraint *myCourseLeftSpace;
    @property (weak, nonatomic) IBOutlet NSLayoutConstraint *myCourseRightSpace;
    
    
    @end
    

    Dashboard.m

    #import "Dashboard.h"
    .
    .
    .
    
    @interface Dashboard ()<UICollectionViewDataSource, UICollectionViewDelegate, UIScrollViewDelegate, SideMenuDelegate, ANGModalDelegate, JTCalendarDelegate, RoboServicesInterfaceDelegate>
    
    
    @end
    
    @implementation Dashboard
    {
        CGPoint currentOffset;
    
        NSArray *scheduleRecord, *subjectsRecord;
    
        SideMenuVC *sideMenuObj;
    
        CALayer *titleLayer, *scheduleLayer;
    
        NSString *token;
    
        CGFloat calCellWd, calCellHt;
    
        NSDate* dateSelected;
        NSUInteger displayingDay, displayingMonth, displayingYear;
    
        NSMutableArray *datesArr;
        NSArray *weekDaysArr;
    
        ANGModal *mod;
    
        JTCalendarMenuView *menuV;
        JTHorizontalCalendarView *horizontalContent;
        JTCalendarManager *calendarManager;
    
        UIView *noScheduleV;
    
        BOOL dateChanged;
    
        NSString *dbPath;
    
        CGFloat otherCellSize;
    
        UIImageView *backImgV;
    
        NSString *userType;
    
        RoboLoaderController *_loaderController;
    }
    
    .
    .
    .
    
    -(void)goBack
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
    .
    .
    .
    -(void)dealloc
    {
        NSLog(@"Released... %s", __PRETTY_FUNCTION__);
    }
    .
    .
    @end
    

    谢谢!

0 个答案:

没有答案