Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Updating the transformKey #19

Open
dotjim opened this issue Jan 30, 2015 · 3 comments
Open

Updating the transformKey #19

dotjim opened this issue Jan 30, 2015 · 3 comments

Comments

@dotjim
Copy link

dotjim commented Jan 30, 2015

Hi there,

Firstly thanks for the great contribution!

Would there be any way to change the transformKey at a later time? The use case I have in mind is to enable namespacing the persisted key/values by something dynamic like a UUID.

-James

@kevinrenskers
Copy link
Contributor

I don't think this is currently possible. I wouldn't mind seeing a PR for this.

@dotjim
Copy link
Author

dotjim commented Feb 3, 2015

I'm not sure my foo is strong enough for a PR, I haven't been able to think of a clean way to achieve this.

My thinking got as far as: ideally we would need to destroy the dynamically created selectors and re-create, which would respect the new transformKey. However Apple deprecated the ability to destroy class_addMethod created selectors (the former class_removeMethods).

Old ones could be swizzled to the new transformKey via class_replaceMethod but this doesn't feel like a clean solution as in essence former selectors will still exist and could be inadvertently called and have unexpected behaviour.

Do you have any ideas on how this could be cleanly accomplished?

@kevinrenskers
Copy link
Contributor

Well the easiest way is to not save the result of the transformKey method, but simply always ask the category for the current value, then you can return whatever you want at that time. But that would be a performance hit...

I don't really see the need for this feature for our apps, so unless it can be done cleanly (and by a contributor like yourself) your best bet would be to use a fork and hack this in your fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants