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 7811003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:59:56+00:00 2026-06-02T03:59:56+00:00

Is it valid to use the __weak storage modifier in a method’s implementation’s signature?

  • 0

Is it valid to use the __weak storage modifier in a method’s implementation’s signature? Especially if it is not part of the method’s public signature? For example:

- (UIView *)tableView:(__weak UITableView *)tableView viewForHeaderInSection:(NSInteger)sectionIndex
{
    UIView *view = [ABHeaderView view];
    view.actionBlock = ^{
        [tableView doSomething];
    }
    // ...
    return view;
}

Does this correctly use tableView as a weak pointer? Or should I really do something like __weak *weakTableView = tableView; and use weakTableView within the block?

I do not get any warnings or errors and the clang Static Analyzer does not throw any warnings.

  • 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-02T03:59:58+00:00Added an answer on June 2, 2026 at 3:59 am

    Don’t count on storage modifiers or attributes to be honored ‘dynamically’ when dynamic dispatch is involved and overriding(1).

    This method is formally declared in UIKit. The compiler may get it wrong when using ARC because it may match the selector to the original declaration when called. That is, your declaration is not visible to UIKit, and UIKit will treat it as default/strong if it’s compiled as ARC as well. This could happen if the declarations do not match, or even if they are not visible in the client+caller translation.

    Parameter types/attributes are not part of the selector, nor are they applied to dispatch dynamically. ARC should assume strong here, and that the caller holds the reference. This specific example may not cause a runtime error, but it’s a questionable practice which I assume errors could be found. I’ve proven this for attributes in this answer. Fundamentally, it is a similar concept.

    Simple rule with dynamic objc dispatch: Always match the signature of the original declaration when redeclaring, defining, and overriding. The only exception one might make is for C compatible qualifiers which would not alter the signature (a very uncommon practice in ObjC programs I’ve seen).

    (1) technically, it’s not an override, but an implementation of the protocol’s method. regardless, the sig should be identical.

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

Sidebar

Related Questions

hi how to use the valid part of an xml present inside a broken
Delphi strings use single quotes, for example ' a valid string '. How does
My question may not make sense but I have valid reason. We use .net
Is it possible that nested calls of io_service.run_one() is not a valid use of
Possible Duplicates: Valid use of goto for error management in C? Examples of good
EDIT: OK, I believe the following solutions are valid: Use the jQuery AOP plugin.
Is this the correct (or even a valid way) to use emums in Objective-C?
Is there any valid use for javascript's encodeURI function? As far as I can
Is it valid to use 2 different CloudQueue objects to manipulate the same queue?
Is there any valid use case for DataSet and DataTable now that we have

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.