-
Notifications
You must be signed in to change notification settings - Fork 4
A couple commits to make life easier and more performant :) #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrebraga
wants to merge
11
commits into
iAOS:master
Choose a base branch
from
andrebraga:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…reate and are likely to be reused with some frequency. Instantiate them lazily however. • Check whether the destination property is primitive or NSNumber-derived, and attempt to parse JSON string values into NSNumbers if so. • Also, pass property_attributes_t by reference instead of copying it.
…d transforms. - OSRKeyPath is inspired by EXTKeyPathCoding (from libextobjc), however it does away with the leading '@' to avoid hidden calls to +[NSString stringWithUTF8String:], simplifies it to always take (instance, key.path) arguments, and expands it to take a (class) type instead of an existing instance, making it usable in class methods without resorting to clunky workarounds. Here's an example: + (NSDictionary *)reflectionMapping { return @{ @"id" : OSRKeyPath(AUser*, Id), @"photos" : OSRTransform(OSRKeyPath(AUser*, pictures)), @"whatevs" : OSRAdapt(OSRKeyPath(AUser*, whatever), AWhateverClass) }; } - (void)reflectionTranformsValue:(id)value forKey:(NSString *)propertyName { if ([propertyName isEqual:OSRKeyPath(self, pictures)]) { self.pictures = [APicture objectsFromDicts:value]; } }
• Address potential differences between external and internal names for uniquing properties • Handle parsing of numbers that are transmitted as strings at the uniquing predicate • Trust key-value coding when the instance is a NSManagedObject (enables value transforms) • Disable the NSCoding default implementation on NSObject(OSReflectionKit) that break NSManagedObject subclasses that are unarchived from the persistent store for not using their designated initialisers. Since the NSCopying implementation was also troublesome for interfering with Core Foundation types (like CGPath on Core Animation APIs), I just disabled them both.
• Minor change for consistency between header and implementation.
…ing recently exposed as the key. Saves *a lot* of trips to Core Data-land.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, still haven't got around reworking the NSCoding/NSCopying code, but here are the couple other niceties I've worked on.
One allows assigning numeric values to numeric properties (both NSNumber and primitives) that exist as strings on the dictionary. Also changed NSDateFormatter allocation to happen statically, but optimised to only instantiate those that are actually requested (big performance boost). Finally changed passing property_attributes_t by reference, which is a small performance boost but nice to have nonetheless since it was trivial.
The other one is a trio of handful macros that help writing key paths and mappings/custom transform, all validated and autocompleted by Xcode. 😸