Reputation: 13
I want to call this method in RestKit RKRoute in swift:
+ (instancetype)routeWithClass:(Class)objectClass pathPattern:(NSString *)pathPattern method:(RKRequestMethod)method;
but I find I can't use 'class' as argument label,the compiler deal it as a keyword
var route:RKRoute = RKRoute(class: Article.self, pathPattern: "/categories/:comment.name/articles/:articleID/comments/", method:RKRequestMethod.GET)
how to call it?
Upvotes: 1
Views: 79
Reputation: 2194
From the Swift documentation:
To use a reserved word as an identifier, put a backtick (`) before and after it. For example, class is not a valid identifier, but `class` is valid. The backticks are not considered part of the identifier; `x` and x have the same meaning.
Thus:
var route:RKRoute = RKRoute(`class`: Article.self, pathPattern: "/categories/:comment.name/articles/:articleID/comments/", method:RKRequestMethod.GET)
Upvotes: 3