TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | BSD |
ReleasedLast Release | Mar 2015 |
Maintained by Yuru Taustahuzau, Nikita Leonov.
A set of reusable components taking advantage of extra dimension Attribute-Oriented Programming adds.
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.
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);
}];
ROAD requires iOS 5.0 and above. The compatibility with 4.3 and older is not tested.
ROAD initially designed to use ARC.
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.
User documentation for the following components is available in Documents folder:
Classes reference is available in cocoadocs.org
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.
There are three ways you can help us: