Skip to content

Change JSONAPIResource protocol func name (Swift 3 compatibility) #48

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Classes/JSONAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ - (void)inflateWithDictionary:(NSDictionary*)dictionary {
JSONAPIResourceDescriptor *desc = [JSONAPIResourceDescriptor forLinkedType:data[@"type"]];

NSMutableDictionary *typeDict = includedResources[desc.type] ?: @{}.mutableCopy;
typeDict[resource.ID] = resource;
typeDict[resource.iD] = resource;

includedResources[desc.type] = typeDict;
}
Expand All @@ -136,7 +136,7 @@ - (void)inflateWithDictionary:(NSDictionary*)dictionary {
JSONAPIResourceDescriptor *desc = [JSONAPIResourceDescriptor forLinkedType:data[@"type"]];

NSMutableDictionary *typeDict = includedResources[desc.type] ?: @{}.mutableCopy;
typeDict[resource.ID] = resource;
typeDict[resource.iD] = resource;

includedResources[desc.type] = typeDict;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ - (NSDictionary *)mapIncludedResources:(NSArray *)relatedResources forResource:(
for (NSObject <JSONAPIResource> *linked in relatedResources) {
JSONAPIResourceDescriptor *desc = [[linked class] descriptor];
NSMutableDictionary *typeDict = includedResources[desc.type] ?: @{}.mutableCopy;
typeDict[linked.ID] = resource;
typeDict[linked.iD] = resource;
includedResources[desc.type] = typeDict;
}
return includedResources;
Expand Down
2 changes: 1 addition & 1 deletion Classes/JSONAPIResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
*
* @return The record identifier for a resource instance.
*/
- (id)ID;
- (id)iD;

/**
* Set the API record identifier for a resource instance. Required for resources that come
Expand Down
8 changes: 4 additions & 4 deletions Classes/JSONAPIResourceParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ + (void)link:(NSObject <JSONAPIResource>*)resource withIncluded:(JSONAPI*)jsonAP
NSObject <JSONAPIResource> *res = obj;
id includedValue = included[[[res.class descriptor] type]];
if (includedValue) {
id v = includedValue[res.ID];
id v = includedValue[res.iD];
if (v != nil) {
matched[idx] = v;
}
Expand All @@ -324,7 +324,7 @@ + (void)link:(NSObject <JSONAPIResource>*)resource withIncluded:(JSONAPI*)jsonAP
id <JSONAPIResource> res = value;
id includedValue = included[[[res.class descriptor] type]];
if (includedValue) {
id v = included[[[res.class descriptor] type]][res.ID];
id v = included[[[res.class descriptor] type]][res.iD];
if (v != nil) {
[resource setValue:v forKey:key];
}
Expand Down Expand Up @@ -371,10 +371,10 @@ + (NSDictionary*)link:(NSObject <JSONAPIResource>*)resource from:(NSObject <JSON
[reference setValue:related forKey:@"related"];
}

if (resource.ID) {
if (resource.iD) {
NSDictionary *referenceObject = @{
@"type" : descriptor.type,
@"id" : resource.ID
@"id" : resource.iD
};
if ([[owner valueForKey:key] isKindOfClass:[NSArray class]]) {
reference = referenceObject.mutableCopy;
Expand Down