Re: Do IMPs move once they're loaded?
Re: Do IMPs move once they're loaded?
- Subject: Re: Do IMPs move once they're loaded?
- From: Ken Tozier <email@hidden>
- Date: Sun, 30 Jan 2005 00:35:33 -0500
On Jan 29, 2005, at 11:08 PM, Brendan Younger wrote:
On Jan 29, 2005, at 9:11 PM, mmalcolm crawford wrote:
On Jan 29, 2005, at 6:25 PM, Ken Tozier wrote:
Once it's in memory, yes. But the dilemma was how to store a
selector along with the data the selector operates on to disk when
the selector itself isn't a fixed length and Apple doesn't guarantee
identical hash values for the identical strings between OS releases.
At any rate, I got it working now. I wrote my own hashing function
(which I won't change between OS releases), store the selector
strings in an NSDictionary in the "initialize" method, and resolve
them as needed with NSSelectorFromString
Perhaps NSInvocation would be more appropriate?
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSInvocation.html>
(Note that it conforms to NSCoding, and instances can be put in
arrays and dictionaries.)
Bad idea. NSInvocation only conforms to NSCoding to support
NSPortCoder; it shouldn't be archived.
As for the original poster's dilemma, there is no need to write your
own hash function; sheesh, just put the selector strings in an
NSDictionary and grab them later.
Anyway, trying to get an optimized special-case method called for a
particular object is what subclasses were invented for. Manually
fooling around trying to determine which type of object you're
handling is terrible design.
If you read a chunk of data off disk and don't know beforehand what
it's type is, you have to do some sort of test, either of a predefined
code, or a string or something saved with the data and dispatch it
yourself. Originally I was hoping that SELs were fixed in size and
value so that it would be possible to save them as a sort of data
prefix and read them back at a later time something like this
(Assume "data_chunk" has just been read from disk)
[self performSelector: *(SEL*) data_chunk ...];
Seemed like a pretty clean way to solve the problem but alas it was not
to be...
Ken
Brendan Younger
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden