Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replacing self->isa because of deprecation

I just installed Xcode 4.6 and now I'm getting new errors in an ancient code I manage.

The compiler complains that "Direct access to objective-c's isa being deprecated in favor of object_setClass() and object_getClass()" and th e project won't build.

So please tell me, is:

object_setClass(self, [CustomClass class]);

the appropriate replacement of:

self->isa = [CustomClass class];

Thank you!

like image 895
EarlGrey Avatar asked Jan 29 '13 19:01

EarlGrey


People also ask

How does depreciation impact taxes?

How does deprecation affect tax liability? Depreciation reduces the taxes your business must pay via deductions by tracking the decrease in the value of your assets. Your business's depreciation expense reduces the earnings on which your taxes are based, which, in turn, reduces the taxes your business owes the IRS.

Where is depreciation on tax return?

Depreciation is the act of writing off a tangible asset over multiple tax years. Depending on your business structure, you list your depreciation deduction each year on Form 1040 (Schedule C), Form 1120/1120S, or Form 1065.

What is depreciation IRS?

Depreciation is the recovery of the cost of the property over a number of years. You deduct a part of the cost every year until you fully recover its cost.

Does a roof replacement qualify for bonus depreciation?

Remember that the IRS classifies some additions and improvements as assets with the same recovery period as the property itself. One of those improvements or additions is a new roof. Due to this, a new roof expense on a rental property does not qualify for bonus depreciation.


1 Answers

Accessing isa has been deprecated for some time, the tools just didn't tell you this. Notably, it's been deprecated for at least as long as tagged pointers have existed in obj-c.

And yes, object_setClass() is the appropriate replacement.

That said, why do you even need this? It's extremely rare that replacing the class of an object is appropriate, and the only valid case I can think of is when you're trying to dynamically subclass a class in order to inject new behavior into individual instances without modifying the class as a whole (which is, of course, something you probably don't need to do).

like image 144
Lily Ballard Avatar answered Sep 22 '22 15:09

Lily Ballard