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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:38:08+00:00 2026-05-27T12:38:08+00:00

I tried to answer Using a UITableView subclass with a UITableViewController with ISA Switching

  • 0

I tried to answer Using a UITableView subclass with a UITableViewController with ISA Switching like so:

self.tableView->isa = [MyTableView class];

But, I get the compile error: Instance variable 'isa' is protected.

Is there a way to get around this? And, if so, is it safe to do?

I’m asking because @AmberStar’s answer to that question seems slightly flawed. (See my comment.)

  • 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-27T12:38:08+00:00Added an answer on May 27, 2026 at 12:38 pm

    If your tableview class provides ANY storage this will break. I would not recommend the path you’re going down. But the correct method would be to use object_setClass(tableView, [MyTableView class]).

    Please make sure this is really what you want.

    Here is a small code-sample showing how this is a horrible idea.

    #import <objc/runtime.h>
    
    @interface BaseClass : NSObject
    {
        int a;
        int b;
    }
    @end
    
    @implementation BaseClass
    
    @end
    
    @interface PlainSubclass : BaseClass
    @end
    
    @implementation PlainSubclass
    @end
    
    @interface StorageSubclass : BaseClass
    {
    @public
        int c;
    }
    @end
    
    @implementation StorageSubclass
    @end
    
    
    
    int main(int argc, char *argv[])
    {
        BaseClass *base = [[BaseClass alloc] init];
        int * random = (int*)malloc(sizeof(int));
        NSLog(@"%@", base);
    
        object_setClass(base, [PlainSubclass class]);
        NSLog(@"%@", base);
    
        object_setClass(base, [StorageSubclass class]);
        NSLog(@"%@", base);
        StorageSubclass *storage = (id)base;
        storage->c = 0xDEADBEEF;
        NSLog(@"%X == %X", storage->c, *random);
    }
    

    and the output

    2011-12-14 16:52:54.886 Test[55081:707] <BaseClass: 0x100114140>
    2011-12-14 16:52:54.889 Test[55081:707] <PlainSubclass: 0x100114140>
    2011-12-14 16:52:54.890 Test[55081:707] <StorageSubclass: 0x100114140>
    2011-12-14 16:52:54.890 Test[55081:707] DEADBEEF == DEADBEEF
    

    As you can see the write to storage->c wrote outside the memory allocated for the instance, and into the block I allocated for random. If that was another object, you just destroyed its isa pointer.

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

Sidebar

Related Questions

I tried following the answer to this question , but could not get xsd.exe
I tried using the answer from here , but it did not work. I
Tried to find answer here but, no luck so, here goes; I would like
i tried googling but didnt get a very specific answer.. then again, i might
I tried googling the answer, but all I found was tips on how to
tried to find the answer by googling and in MSDN but with no luck.
I've tried to find an answer to do this online but apparently it can't
Ok, I have tried searching around for this answer, but with no luck. I
Ok, this probably has a really simple answer, but I've never tried to do
I have tried finding a simialr example and using that to answer my problem,

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.