Skip to content

Commit

Permalink
Updated name again for AFNetworking example server
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Stoll committed Mar 1, 2014
1 parent 58f1975 commit d212e71
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

##[1.3.0](https://github.com/mutualmobile/MMRecord/issues?milestone=6&state=closed) (Friday, March 7th, 2014)
###New
* Added a new subspec called AFMMRecordServer that provides an example server for using AFNetworking 2.0. (Conrad Stoll)
* Added a new subspec called SessionManagerServer that provides an example server for using AFNetworking 2.0. (Conrad Stoll)
* Added a new way to inject a primary key into the population system. (Conrad Stoll)
* Added a new option for performing pre-population steps in the population system. (Conrad Stoll)
* Added new safeguards against creating duplicate records when using relationship primary keys. (Conrad Stoll)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
55D278BB18298377008CB6B4 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D278BA18298377008CB6B4 /* CoreLocation.framework */; };
55DB69CA184E66AA00677CEA /* Venues.json in Resources */ = {isa = PBXBuildFile; fileRef = 55DB69C9184E66AA00677CEA /* Venues.json */; };
55DB69CC184E66F400677CEA /* Venue.json in Resources */ = {isa = PBXBuildFile; fileRef = 55DB69CB184E66F400677CEA /* Venue.json */; };
55DD2B1D18C136DF00CF044B /* AFMMRecordServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 55DD2B1C18C136DF00CF044B /* AFMMRecordServer.m */; };
55F8C4BB1848F8E000037D45 /* AFMMRecordResponseSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F8C4BA1848F8E000037D45 /* AFMMRecordResponseSerializer.m */; };
55FB3C1A18C1A10400B861BA /* AFMMRecordSessionManagerServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 55FB3C1918C1A10400B861BA /* AFMMRecordSessionManagerServer.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -160,10 +160,10 @@
55D278BA18298377008CB6B4 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
55DB69C9184E66AA00677CEA /* Venues.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Venues.json; sourceTree = "<group>"; };
55DB69CB184E66F400677CEA /* Venue.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Venue.json; sourceTree = "<group>"; };
55DD2B1B18C136DF00CF044B /* AFMMRecordServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFMMRecordServer.h; sourceTree = "<group>"; };
55DD2B1C18C136DF00CF044B /* AFMMRecordServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFMMRecordServer.m; sourceTree = "<group>"; };
55F8C4B91848F8E000037D45 /* AFMMRecordResponseSerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFMMRecordResponseSerializer.h; sourceTree = "<group>"; };
55F8C4BA1848F8E000037D45 /* AFMMRecordResponseSerializer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFMMRecordResponseSerializer.m; sourceTree = "<group>"; };
55FB3C1818C1A10400B861BA /* AFMMRecordSessionManagerServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFMMRecordSessionManagerServer.h; sourceTree = "<group>"; };
55FB3C1918C1A10400B861BA /* AFMMRecordSessionManagerServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFMMRecordSessionManagerServer.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -283,9 +283,9 @@
55D278411829769B008CB6B4 /* Vendor */ = {
isa = PBXGroup;
children = (
55DD2B1A18C136DF00CF044B /* AFMMRecordServer */,
55D278421829769B008CB6B4 /* AFNetworking */,
55F8C4B81848F8E000037D45 /* AFMMRecordResponseSerializer */,
55FB3C1718C1A10400B861BA /* AFMMRecordSessionManagerServer */,
55D2789018297E01008CB6B4 /* MMRecord */,
);
path = Vendor;
Expand Down Expand Up @@ -417,16 +417,6 @@
name = Resources;
sourceTree = "<group>";
};
55DD2B1A18C136DF00CF044B /* AFMMRecordServer */ = {
isa = PBXGroup;
children = (
55DD2B1B18C136DF00CF044B /* AFMMRecordServer.h */,
55DD2B1C18C136DF00CF044B /* AFMMRecordServer.m */,
);
name = AFMMRecordServer;
path = ../../../../../Source/AFMMRecordServer;
sourceTree = "<group>";
};
55F8C4B81848F8E000037D45 /* AFMMRecordResponseSerializer */ = {
isa = PBXGroup;
children = (
Expand All @@ -439,6 +429,16 @@
path = ../../../../../Source/AFMMRecordResponseSerializer;
sourceTree = "<group>";
};
55FB3C1718C1A10400B861BA /* AFMMRecordSessionManagerServer */ = {
isa = PBXGroup;
children = (
55FB3C1818C1A10400B861BA /* AFMMRecordSessionManagerServer.h */,
55FB3C1918C1A10400B861BA /* AFMMRecordSessionManagerServer.m */,
);
name = AFMMRecordSessionManagerServer;
path = ../../../../../Source/AFMMRecordSessionManagerServer;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -550,7 +550,6 @@
55D2785D1829769B008CB6B4 /* AFURLResponseSerialization.m in Sources */,
55D2785B1829769B008CB6B4 /* AFURLConnectionOperation.m in Sources */,
55D27866182977F5008CB6B4 /* MMFoursquareSessionManager.m in Sources */,
55DD2B1D18C136DF00CF044B /* AFMMRecordServer.m in Sources */,
55D2785A1829769B008CB6B4 /* AFSecurityPolicy.m in Sources */,
55D278AD18297E01008CB6B4 /* MMServerPageManager.m in Sources */,
55D278581829769B008CB6B4 /* AFHTTPSessionManager.m in Sources */,
Expand All @@ -559,6 +558,7 @@
550DFAA41846AF2300E76A6B /* Menu.m in Sources */,
26F9870A18666C03000CAF96 /* MMViewController.m in Sources */,
55D278AA18297E01008CB6B4 /* MMRecordRepresentation.m in Sources */,
55FB3C1A18C1A10400B861BA /* AFMMRecordSessionManagerServer.m in Sources */,
55D278B2182980BC008CB6B4 /* FSRecord.m in Sources */,
55D278A618297E01008CB6B4 /* MMRecord.m in Sources */,
55D278A818297E01008CB6B4 /* MMRecordMarshaler.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#import "AFMMRecordResponseSerializer.h"
#import "AFMMRecordResponseSerializationMapper.h"
#import "AFMMRecordServer.h"
#import "AFMMRecordSessionManagerServer.h"
#import "FSRecord.h"
#import "MMDataManager.h"
#import "MMFoursquareSessionManager.h"
Expand All @@ -20,8 +20,8 @@ @implementation MMAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MMFoursquareSessionManager *serverClientManager = [MMFoursquareSessionManager serverClient];

[AFMMRecordServer registerAFHTTPSessionManager:serverClientManager];
[FSRecord registerServerClass:[AFMMRecordServer class]];
[AFMMRecordSessionManagerServer registerAFHTTPSessionManager:serverClientManager];
[FSRecord registerServerClass:[AFMMRecordSessionManagerServer class]];

MMFoursquareSessionManager *sessionManager = [MMFoursquareSessionManager sharedClient];

Expand Down
8 changes: 4 additions & 4 deletions MMRecord.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ Pod::Spec.new do |s|
ser.dependency 'MMRecord/Core'
end

s.subspec 'AFMMRecordServer' do |afserv|
afserv.source_files = 'Source/AFMMRecordServer/*.{h,m}'
afserv.dependency 'AFNetworking', '>= 2.0'
afserv.dependency 'MMRecord/Core'
s.subspec 'SessionManagerServer' do |sms|
sms.source_files = 'Source/AFMMRecordSessionManagerServer/*.{h,m}'
sms.dependency 'AFNetworking', '>= 2.0'
sms.dependency 'MMRecord/Core'
end

end
8 changes: 4 additions & 4 deletions MMRecord.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ The library is architected to be as simple and lightweight as possible. Here's a
<td>An example <tt>MMServer</tt> subclass that implements <tt>AFNetworking</tt> 1.0.</td>
</tr>
<tr>
<td><a href="https://github.com/mutualmobile/MMRecord/tree/master/Source/MMRecordAFServer">AFMMRecordServer</a></td>
<td><a href="https://github.com/mutualmobile/MMRecord/tree/master/Source/AFMMRecordSessionManagerServer">SessionManagerServer</a></td>
<td>An example <tt>MMServer</tt> subclass that implements <tt>AFNetworking</tt> 2.0.</td>
</tr>
<tr>
Expand All @@ -128,7 +128,7 @@ The library is architected to be as simple and lightweight as possible. Here's a
</tr>
<tr>
<td><a href="https://github.com/mutualmobile/MMRecord/tree/master/Source/MMRecordDynamicModel">DynamicModel</a></td>
<td>A custom <tt>MMRecordRepresentation</tt> and <tt>MMRecordMarshaler</tt> pair that stores the original object dictionary as a transformable attribute.</td>
<td>A custom <tt>MMRecordRepresentation</tt> and <tt>MMRecordMarshaler</tt> subclass pair that stores the original object dictionary as a transformable attribute.</td>
</tr>
<tr>
<td><a href="https://github.com/mutualmobile/MMRecord/tree/master/Source/AFMMRecordResponseSerializer">ResponseSerializer</a></td>
Expand Down Expand Up @@ -159,11 +159,11 @@ Note that you can register different server classes on different subclasses of M

This is helpful if one endpoint you are working with is complete, but another is not, or is located on another API.

#### AFNetworking 2.0
#### AFNetworking

While you are encouraged to create your own specific server subclass for your own integration, MMRecord does provide a subspec example for AFNetworking 1.0 and AFNetworking 2.0. You can consult the MMRecordAFServer subspec for AFNetworking 1.0, or the AFMMRecordServer subspec for AFNetworking 2.0 support.
While you are encouraged to create your own specific server subclass for your own integration, MMRecord does provide base server implementations as subspec examples for AFNetworking 1.0 and AFNetworking 2.0. You can consult the AFServer subspec for AFNetworking 1.0, or the AFMMRecordSessionManagerServer subspec for AFNetworking 2.0. You can check out the new AFNetworking 2.0 server in the [Foursquare example app](https://github.com/mutualmobile/MMRecord/tree/master/Examples/MMRecordFoursquare/MMRecordFoursquare).

In addition, we provide the AFMMRecordResponseSerializer subspec specifically for AFNetworking 2.0. This response serializer can be used for AFNetworking 2.0 in order to provide parsed and populated MMRecord instances to you in an AFNetworking success block. For more information please check out this [blog post](https://mutualmobile.github.io/blog/2014/01/14/afnetworking-response-serialization-with-mmrecord-1-dot-2/) or view the example [below](https://github.com/mutualmobile/MMRecord/#afmmrecordresponseserializer).
In addition, we provide the AFMMRecordResponseSerializer subspec specially for AFNetworking 2.0. This response serializer can be used for AFNetworking 2.0 in order to provide parsed and populated MMRecord instances to you in an AFNetworking success block. For more information please check out this [blog post](https://mutualmobile.github.io/blog/2014/01/14/afnetworking-response-serialization-with-mmrecord-1-dot-2/) or view the example [below](https://github.com/mutualmobile/MMRecord/#afmmrecordresponseserializer).

### MMRecord Subclass Implementation

Expand Down Expand Up @@ -345,7 +345,9 @@ fetchRequest.sortDescriptors = @[sortDescriptor];
failureBlock:failureBlock];
```
### MMRecordOptions and Primary Key Injection
## MMRecordOptions Examples
### Primary Key Injection
```objective-c
MMRecordOptions *options = [Post defaultOptions];
Expand All @@ -372,9 +374,37 @@ options.entityPrimaryKeyInjectionBlock = ^id(NSEntityDescription *entity,
resultBlock:^(NSArray *posts, ADNPageManager *pageManager, BOOL *requestNextPage) {
[self populatePostsTableWithPosts:posts];
}
failureBlock:^(NSError *error) {
[self endRequestingPosts];
}];
failureBlock:failureBlock];
```

### Orphan Deletion

```objective-c
MMRecordOptions *options = [Tweet defaultOptions];

options.deleteOrphanedRecordBlock = ^(MMRecord *orphan,
NSArray *populatedRecords,
id responseObject,
BOOL *stop) {
Tweet *tweet = (Tweet *)orphan;
if ([tweet isFavorite]) {
return NO;
}
return YES;
};

[Tweet setOptions:options];

[Tweet
timelineTweetsWithContext:context
domain:self
resultBlock:^(NSArray *tweets, MMServerPageManager *pageManager, BOOL *requestNextPage) {
self.tweets = tweets;
[self.tableView reloadData];
}
failureBlock:failureBlock];
```
### AFMMRecordResponseSerializer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// AFServer.h
// AFMMRecordSessionManagerServer.h
//
// Copyright (c) 2014 Mutual Mobile (https://www.mutualmobile.com/)
//
Expand Down Expand Up @@ -64,7 +64,7 @@
*/


@interface AFMMRecordServer : MMServer
@interface AFMMRecordSessionManagerServer : MMServer

/**
This method can be used to register an instance of an AFHTTPSessionManager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// AFServer.m
// AFMMRecordSessionManagerServer.m
//
// Copyright (c) 2014 Mutual Mobile (https://www.mutualmobile.com/)
//
Expand All @@ -20,14 +20,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "AFMMRecordServer.h"
#import "AFMMRecordSessionManagerServer.h"

#import <objc/runtime.h>
#import "AFHTTPSessionManager.h"

static id AFServer_registeredAFSessionManager;

@implementation AFMMRecordServer
@implementation AFMMRecordSessionManagerServer

+ (BOOL)registerAFHTTPSessionManager:(id)sessionManager {
if ([sessionManager isKindOfClass:[AFHTTPSessionManager class]] ||
Expand Down

0 comments on commit d212e71

Please sign in to comment.