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

  • SEARCH
  • Home
  • 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 3801452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:03:09+00:00 2026-05-19T14:03:09+00:00

When creating a custom UITableView cell I manually define a delegate variable in the

  • 0

When creating a custom UITableView cell I manually define a delegate variable in the @interface of a UITableViewCell class (each cell must communicate with parent class so the connection betweet two classes is needed). Then when a cell is attached to a UITableView, I just set that delegate variable.

@interface MyCellClass : UITableViewCell {
   MyParentController *delegat;
}
@property (nonatomic, retain) MyParentController *delegat;

Is there a better way of doing it?

  • 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-05-19T14:03:10+00:00Added an answer on May 19, 2026 at 2:03 pm

    That could be ok but be sure you don’t make retain cycles. (A retains B, B retains A, none of them get never released)

    If you are just using only a functionality of MyParentController then, it is a good idea to make a protocol and set a delegate as an object that adopts (implements) that @protocol, It is not mandatory but it is good practice and better design this way.

    You could create your protocol like:

    //MyProtocol.h
    @protocol MyProtocol <NSObject>
    
    @required
    - (void) requiredMethod:(NSString *)param;
    @optional
    - (void) optionalMethod:(NSString *)param;
    @end
    

    And Make your class:

    #import "MyProtocol.h"
    
    @interface MyCellClass : UITableViewCell {
       id<MyProtocol> delegate;
    }
    @property (nonatomic, assign) id<MyProtocol> delegate; //see I changed it to assign?
    

    Also, when you have delegates you should avoid making them retain or you will have retain cycles and hence, memory leaks.

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

Sidebar

Related Questions

I am creating a custom UITableViewCell class in my iPhone app, but I am
I'm creating custom UITableViewCells using the approach outlined on this page: http://icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/ So my
I have a custom UITableView class for creating shadow effects on all of my
I'm creating a custom control, part of which is using the Graphics class to
I have a custom UITableViewCell which I created in Interface Builder. I am successfully
I am creating a custom UITableViewCell to include an UIImageView and some related text.
I am creating a custom UITableViewCell with UILabel inside. When I am setting too
Each cell of my UITableView has to display a small MKMapView with an annotation
Hopefully a quick one? I am creating a custom uitableviewcell and have added an
i am creating a Custom reusable UITableViewCell with Three labels and one imageView,and i

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.