Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: const Object cannot receive messages in 10.4



If I try to send a message to a variable defined as const Object *, I get a warning: "warning: invalid receiver type 'Object *'". I'm currently fixing this by removing a bunch of "const" qualifiers from my code, but am curious as to what is causing the error and what has changed.

I'm surprised you ever got this working - Objective-C doesn't use the C++ style for immutable objects, but rather builds [im]mutability into class design. You'll rarely, if ever, actually want a const object, since you can't message it.


As an analogy, consider a const class reference in C++, and what happens when you call any method not qualified as "const" - it won't work, either. Objective-C has no equivalent "const" qualifier for methods, that I'm aware of.

I know from my own experience this didn't work on some previous version of MacOS X - 10.3 or possibly 10.2. Did you do anything unusual to get the compiler to accept it to start with?

Wade Tregaskis (AIM/iChat, Yahoo, Gizmo & Skype: wadetregaskis, ICQ: 40056898, MSN: email@hidden, AV iChat & email: email@hidden, Jabber: email@hidden)
-- Sed quis custodiet ipsos custodes?


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >const Object cannot receive messages in 10.4 (From: Andrew White <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.