A set of reusable components taking advantage of extra dimension Attribute-Oriented Programming adds.
##Components
Core - support for attributes, reflection and helper-extensions on Foundation classes.
Services - implementation of Service Locator pattern, centralized replacement for singletons.
Serialization - attribute-based JSON and XML parsers for easy DOM (de)serializations.
Web Services - attribute-based HTTP client API.
##Snippet Connection to the test HTTP server, that returns JSON from headers you send, could look as follows:
RF_ATTRIBUTE(RFWebService, serviceRoot = @"http://headers.jsontest.com/")
@interface JsonTestWebClient : RFWebServiceClient
RF_ATTRIBUTE(RFWebServiceCall, method = @"GET", prototypeClass = [MyWebServiceResponse class])
RF_ATTRIBUTE(RFWebServiceHeader, headerFields = @{@"Text" : @"A lot of text",
@"Number" : [@1434252.234 stringValue],
@"Date" : [[NSDate dateWithTimeIntervalSince1970:100000000] description]})
- (id<RFWebServiceCancellable>)echoRequestHeadersAsJSONWithSuccess:(void(^)(MyWebServiceResponse result))successBlock failure:(void(^)(NSError *error))failureBlock;
@end
then we define the model:
RF_ATTRIBUTE(RFSerializable)
@interface MyWebServiceResponse : NSObject
RF_ATTRIBUTE(RFSerializable, serializationKey = @"Text")
@property NSString *text;
RF_ATTRIBUTE(RFSerializable, serializationKey = @"Number")
@property NSNumber *number;
RF_ATTRIBUTE(RFSerializable, serializationKey = @"Date")
RF_ATTRIBUTE(RFSerializableDate, format = @"yyyy-MM-dd HH:mm:ss Z")
@property NSDate *date;
@end
and make singleton instance of JsonTestWebClient accessible through RFServiceProvider:
@interface RFServiceProvider (JsonTestWebClient)
RF_ATTRIBUTE(RFService, serviceClass = [JsonTestWebClient class])
+ (JsonTestWebClient *)jsonTestWebClient;
@end
Now we can use it:
[[RFServiceProvider jsonTestWebClient] echoRequestHeadersAsJSONWithSuccess:^(MyWebServiceResponse *result) {
NSLog(@"%@", result);
} failure:^(NSError *error) {
NSLog(@"Something terrible happened! Here are details : %@", error);
}];
##Requirements
ROAD requires iOS 5.0 and above. The compatibility with 4.3 and older is not tested.
ROAD initially designed to use ARC.
##Jump Start CocoaPods is the only recommended way of ROAD integration. Besides the standard configuration of pod dependencies, pod_install hook is required as shown below. A typical Podfile will look as follows:
pod 'ROADFramework'
post_install do |installer|
require File.expand_path('ROADConfigurator.rb', './Pods/libObjCAttr/libObjCAttr/Resources/')
ROADConfigurator::post_install(installer)
end
Using components separately
If you'd like to embed only specific components from the framework it can be done with CocoaPods as well.
pod 'ROADFramework/ROADServices'
pod 'ROADFramework/ROADWebService'
Detailed information on internals of ROAD integration as well as advanced topics like integration with predefined workspace, multiple projects or targets is available in the documentation.
##Documentation
User documentation for the following components is available in Documents folder:
Classes reference is available in cocoadocs.org
##License ROAD is made available under the terms of the BSD-3. Open the LICENSE file that accompanies this distribution in order to see the full text of the license.
##Contribution
There are three ways you can help us:
- Raise an issue. You found something that does not work as expected? Let us know about it.
- Suggest a feature. It's even better if you come up with a new feature and write us about it.
- Write some code. We would love to see more pull requests to our framework, just make sure you have the latest sources. For more information, check out the guidelines for contributing.