RKRoute Class Reference
| Inherits from | NSObject |
| Declared in | RKRoute.h |
Overview
The RKRoute class models a single routable path pattern in use by the application. A route can be combined with an NSURL base URL and interpolated with an object to produce a new fully hydrated URL object. Routes are always instantiated with a path pattern and metadata to provide for the subsequent identification of the defined route.
There are three types of routes modeled by the RKRoute class:
- Named Routes: A named route represents a single path and optional request method within the application. The route is not affiliated with any particular class. For example, one might define a route with the name
@"airlines_list"as a GET to the path ‘/airlines.json’. - Class Routes: An class route represents a single path that is identified by object class and request method for which it is appropriate. For example, one might define a route for the class
RKArticlefor a POST to the path ‘/articles.json’. - Relationship Routes: A relationship route represents a single path through which the relationship of a parent object can be manipulated. For example, given an
RKArticleandRKCommentclass, one might define a relationship route for theRKArticleclass’s@"comments"relationship as pointing to a GET to the path `@“/articles/:articleID/comments”.
The RKRoute class is internally implemented as a class cluster and is not to be directly instantiated via alloc and init.
Tasks
Instantiating Routes
-
+ routeWithName:pathPattern:method:Creates and returns a new named route object with the given name, path pattern and method.
-
+ routeWithClass:pathPattern:method:Creates and returns a new class route object with the given object class, path pattern and method.
-
+ routeWithRelationshipName:objectClass:pathPattern:method:Creates and returns a new relationship route object with the given relationship name, object class, path pattern and method.
Accessing Route Attributes
-
nameThe name of the receiver.
property -
objectClassThe object class of the receiver.
property -
methodThe request method of the receiver.
property -
pathPatternThe path pattern of the receiver.
property -
shouldEscapePathA Boolean value that determines if the path pattern should be escaped when evaluated.
property
Inspecting Route Types
-
– isNamedRouteDetermines if the receiver is a named route.
-
– isClassRouteDetermines if the receiver is a class route.
-
– isRelationshipRouteDetermines if the receiver is a relationship route.
Properties
method
The request method of the receiver.
@property (nonatomic, assign, readonly) RKRequestMethod methodDiscussion
Appropriate for all route types. If the route is appropriate for any HTTP request method, then the RKRequestMethodAny value is used.
Declared In
RKRoute.hname
The name of the receiver.
@property (nonatomic, strong, readonly) NSString *nameDiscussion
The name is used to identify named and relationship routes and is always nil for object routes.
Declared In
RKRoute.hobjectClass
The object class of the receiver.
@property (nonatomic, strong, readonly) Class objectClassDiscussion
Defines the class for which the route is appropriate. Always returns nil for named routes.
Declared In
RKRoute.hClass Methods
routeWithClass:pathPattern:method:
Creates and returns a new class route object with the given object class, path pattern and method.
+ (instancetype)routeWithClass:(Class)objectClass pathPattern:(NSString *)pathPattern method:(RKRequestMethod)methodParameters
- objectClass
The class that is represented by the route.
- pathPattern
A SOCKit pattern describing the format of URL paths generated from the route.
- method
The request method of the route.
Return Value
A new class route object with the given object class, path pattern and request method.
Declared In
RKRoute.hrouteWithName:pathPattern:method:
+ (instancetype)routeWithName:(NSString *)name pathPattern:(NSString *)pathPattern method:(RKRequestMethod)methodParameters
- name
A unique identifying name for the route.
- pathPattern
A SOCKit pattern describing the format of URL paths generated from the route.
- method
The request method of the route.
Declared In
RKRoute.hrouteWithRelationshipName:objectClass:pathPattern:method:
Creates and returns a new relationship route object with the given relationship name, object class, path pattern and method.
+ (instancetype)routeWithRelationshipName:(NSString *)name objectClass:(Class)objectClass pathPattern:(NSString *)pathPattern method:(RKRequestMethod)methodParameters
- name
The name of the relationship represented by the route.
- objectClass
The class containing the relationship represented by the route.
- pathPattern
A SOCKit pattern describing the format of URL paths generated from the route.
- method
The request method of the route.
Return Value
A new class route object with the given object class, path pattern and request method.
Declared In
RKRoute.hInstance Methods
isClassRoute
Determines if the receiver is a class route.
- (BOOL)isClassRouteReturn Value
YES if the receiver is a class route, else NO.
Declared In
RKRoute.h