This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
Make NSCoding implementation always encode properties to NSData, and de... #40
Closed
marklarr
wants to merge
3
commits into
dingbat:master
from
marklarr:init_with_needs_set_remote_properties
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ a copy of this software and associated documentation files (the | |
|
||
@interface NSRRemoteObject (private) | ||
|
||
- (NSDictionary *) remoteDictionaryRepresentationWrapped:(BOOL)wrapped fromNesting:(BOOL)nesting; | ||
- (NSDictionary *) dictionaryRepresentationWrapped:(BOOL)wrapped fromNesting:(BOOL)nesting remoteOnly:(BOOL)remote; | ||
+ (NSArray *) arrayOfInstancesFromRemoteJSON:(id)json; | ||
|
||
- (BOOL) propertyIsTimestamp:(NSString *)property; | ||
|
@@ -209,14 +209,18 @@ - (id) encodeValueForProperty:(NSString *)property remoteKey:(NSString **)remote | |
|
||
for (id element in val) | ||
{ | ||
id encodedObj = [element remoteDictionaryRepresentationWrapped:NO fromNesting:YES]; | ||
id encodedObj = [element dictionaryRepresentationWrapped:NO | ||
fromNesting:YES | ||
remoteOnly:YES]; | ||
[new addObject:encodedObj]; | ||
} | ||
|
||
return new; | ||
} | ||
|
||
return [val remoteDictionaryRepresentationWrapped:NO fromNesting:YES]; | ||
return [val dictionaryRepresentationWrapped:NO | ||
fromNesting:YES | ||
remoteOnly:YES]; | ||
} | ||
|
||
if ([val isKindOfClass:[NSDate class]]) | ||
|
@@ -383,16 +387,16 @@ - (void) setPropertiesUsingRemoteDictionary:(NSDictionary *)dict | |
|
||
- (NSDictionary *) remoteDictionaryRepresentationWrapped:(BOOL)wrapped | ||
{ | ||
return [self remoteDictionaryRepresentationWrapped:wrapped fromNesting:NO]; | ||
return [self dictionaryRepresentationWrapped:wrapped fromNesting:NO remoteOnly:YES]; | ||
} | ||
|
||
- (NSDictionary *) remoteDictionaryRepresentationWrapped:(BOOL)wrapped fromNesting:(BOOL)nesting | ||
- (NSDictionary *) dictionaryRepresentationWrapped:(BOOL)wrapped fromNesting:(BOOL)nesting remoteOnly:(BOOL)remote | ||
{ | ||
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; | ||
|
||
for (NSString *objcProperty in [self remoteProperties]) | ||
{ | ||
if (![self shouldSendProperty:objcProperty whenNested:nesting]) | ||
if (remote && ![self shouldSendProperty:objcProperty whenNested:nesting]) | ||
continue; | ||
|
||
NSString *remoteKey = objcProperty; | ||
|
@@ -607,6 +611,7 @@ - (id) initWithCoder:(NSCoder *)aDecoder | |
{ | ||
self.remoteID = [aDecoder decodeObjectForKey:@"remoteID"]; | ||
remoteAttributes = [aDecoder decodeObjectForKey:@"remoteAttributes"]; | ||
[self setPropertiesUsingRemoteDictionary:remoteAttributes]; | ||
self.remoteDestroyOnNesting = [aDecoder decodeBoolForKey:@"remoteDestroyOnNesting"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My tabbing isn't like this here, either! Very confused.. |
||
} | ||
return self; | ||
|
@@ -615,7 +620,10 @@ - (id) initWithCoder:(NSCoder *)aDecoder | |
- (void) encodeWithCoder:(NSCoder *)aCoder | ||
{ | ||
[aCoder encodeObject:self.remoteID forKey:@"remoteID"]; | ||
[aCoder encodeObject:remoteAttributes forKey:@"remoteAttributes"]; | ||
[aCoder encodeObject:[self dictionaryRepresentationWrapped:NO | ||
fromNesting:NO | ||
remoteOnly:NO] | ||
forKey:@"remoteAttributes"]; | ||
[aCoder encodeBool:remoteDestroyOnNesting forKey:@"remoteDestroyOnNesting"]; | ||
} | ||
|
||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird... the colons are matching up in xCode, for me. Have you ever heard this happen before?