Skip to content

Instantly share code, notes, and snippets.

@edopelawi
Created September 26, 2015 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edopelawi/bc65b7eed025be56be33 to your computer and use it in GitHub Desktop.
Save edopelawi/bc65b7eed025be56be33 to your computer and use it in GitHub Desktop.
Slightly better than JumbledParamaterNetworkService.m . Here, you can move the payload creation (plus all the check it needs) to RPSUser class.
@class RPSUser
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *email;
@property (nonatomic, copy) NSString *address;
/// Used only to create @p payloadDictionary.
@property (nonatomic, copy) NSString *password;
/// Payload dictionary made from this instance's properties.
- (NSDictionary *)payloadDictonary;
/// Rest of your implementation here...
@end
/// The result of this method will be sent via the @p RACSignal.
- (RACSignal *)registerNewUser:(RPSUser *)user
{
NSDictionary *payload = [user payloadDictionary];
// More logic or network call here...
return networkRequestSignal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment