Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:52:46+00:00 2026-06-03T07:52:46+00:00

#import <UIKit/UIKit.h> #import UCMapviewController.h #import UCMenuviewController.h #import UCOverviewController.h @interface UCRootViewController : UIViewController @property (weak,

  • 0
#import <UIKit/UIKit.h>
#import "UCMapviewController.h"
#import "UCMenuviewController.h"
#import "UCOverviewController.h"

@interface UCRootViewController : UIViewController

@property (weak, nonatomic) UCMapviewController *mapviewController;
@property (weak, nonatomic) UCMenuviewController *menuviewController;
@property (weak, nonatomic) UCOverviewController *overviewController;

This is the declaration of my UCRootViewController which should manage these sub-viewControllers. He will later also become their delegate to handle when one controller should be shown or not.

The rootViewController is held strong in the UIAppDelegate and will remain active all the time.

So is it correct to make those sub-viewControllers weak? I’m not 100% sure, but as far as I understand weak pointers get deallocated when there is no strong pointer pointing to them. So as the root is strong, it’s correct to make them weak, right?

#import <UIKit/UIKit.h>

@class UCRootViewController;
@interface UCOverviewController : UIViewController

@property (weak, nonatomic) UCRootViewController *rootviewController;

This is the header of one of my sub-viewControllers. They have a weak pointer to the (later) delegate rootviewController. Is it enough to declare @class UCRootviewController to make them call the delegate methods? Do I even need this?

thanks

EDIT: I just read a nice article about ViewControllers and the passage:

Always use high-quality view controller containers or
+[UIViewController presentModalViewController:animated:] to display view controllers in your application. If you need to keep a reference
to a view controller somewhere, use a weak reference, except if you
really want it to stay alive longer for caching purposes. In such
cases, be sure to correctly respond to low-memory conditions.

It says use a weak reference, what’s your opinions on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:52:47+00:00Added an answer on June 3, 2026 at 7:52 am

    The strong pointer only ties into your rootViewController. This doesn’t mean that it will automatically strong point to your other viewControllers inside your rootViewController.

    You should set those properties to strong, to make sure that your other viewControllers won’t get deallocated in any way you don’t want them to.

    If you push them into a navigation stack it will be fine, because the navigation stack automatically strongs points to them. But if you’re just going to add their views as subviews in your rootViewController, then you want to make sure that those properties are strong.

    Objects get deallocated when there is no strong pointer to them. And as there are no strong pointers to your other viewControllers they will get deallocated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#import <UIKit/UIKit.h> #import UCMapviewController.h #import UCMenuviewController.h #import UCOverviewController.h @interface UCRootViewController : UIViewController @property (strong,
h #import <UIKit/UIKit.h> @interface LoginViewController : UIViewController <UITextFieldDelegate> @property (nonatomic, retain) NSDictionary *_data; @end
In this code: #import <UIKit/UIKit.h> @interface ViewController : UIViewController { UILabel *labelsText; } @property(strong,
I have declared this ivar in my ViewController.h #import <UIKit/UIKit.h> @interface FirstViewController : UIViewController
Say I have this code: #import <UIKit/UIKit.h> @interface MyView : UIView @end @implementation MyView
I have some codes as below #import <UIKit/UIKit.h> @interface ViewMoreSettingController : UIViewController < UITableViewDelegate,
I use this library: https://github.com/robbiehanson/CocoaAsyncSocket My test code: #import <UIKit/UIKit.h> @class GCDAsyncUdpSocket; @interface ThirdViewController
I just create a simple UITableView in the UIViewController . .h #import <UIKit/UIKit.h> @interface
#import <UIKit/UIKit.h> @interface quartzViewController : UIViewController { IBOutlet UIView *myView; } @end #import quartzViewController.h
QuestionsViewController.h: #import <UIKit/UIKit.h> @interface QuestionsViewController : UIViewController { int currentQuestionIndex; NSMutableArray *questions; IBOutlet UILabel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.