Multiple declarations and the ID type
Multiple declarations and the ID type
- Subject: Multiple declarations and the ID type
- From: Jamie <email@hidden>
- Date: Mon, 21 Jun 2004 17:31:49 +0100
I am having an annoying problem with warnings being issued from the
compiler when I am building my app.
I have an instance variable of type ID, that gets assigned different
object types that it has to deal with. Each of these objects has a
method
- (void) setName: (NSString *) theName;
The problem is that because I am dynamically typing, the compiler
doesn't know whether to use that definition or one of another two it
finds in the other headers that are included in my project, and I get a
multiple declarations error.
I have trawled the archives but have found no viable solution to this
issue for my case. The only fix I can think of at the moment is to
change the variable and method names to something unique, but that
seems like a copout. The two suggestions I have read are - to cast the
variable as you send the message, but that is not possible since it
could be one of three different classes, and the other is to statically
type it - also not possible.
I tried creating a parent class so that it would just contain that
method, and maybe a few other common ones, so that I could statically
type the variable, but then i got the inverse of the problem: because
not all subclasses responded to the same methods, I get "object may not
respond to -selector". Basically it seems like catch 22. How can get
rid of this error?
PS - I do understand why I get the mesages, i just don't see a way
round it in my case. I thought the idea of dynamic typing was for
situations such as this where you don't know what type your object will
be - great, but not if it leaves you with loads of warnings and badly
compiled code.
--
jkp
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGP 8.0.3
mQGiBEAvrCkRBADP0l+qGhYxe7VZe8NhHPvHKGfYEzMg/FpZxqRY179JI2EAPM4P
ojR8YuTmFDEPgz+4Ae4IUIJyhJBean5D/CFy3TpHYTUlK3eA1cH7PDNOW7oTGSmM
+zRkD1HnkaPVwylmNvI4RmceA0JuhCi9Y35Bkxa1yBLLB+uRC1Zf4+Ek/QCg/4Jh
161Ewn5UOV2eAmxFFRmyCLsD/jCeNrU4w5i/8YLoVFy3vZYhNsPL299vNc/PmF+h
+NPbbWAgay2UVnyc0lkbtOr+ZiEjgf0ltr3rDrjaF6faxwo8sDE5Tuh1yUUJ5Ngv
VLgyDLn9ChnOxiKYGZeI173JXYYhk3V8eU8qtIdH+IBQeHJjeWJg4dKRNqqDzlaI
r3GmA/9S11g+wKWYwKUNbPqRp29KuiRkIN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Q4RXc3SiZNM/0VACeORa/zYtGyekOwxUXzW5BQqdlsjIAoPhHLTE5Kwcq
2WgOOCUuqD0QoU8e
=/4Ed
-----END PGP PUBLIC KEY BLOCK-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.