7
मैं एक एंडपॉइंट कॉल करने के लिए रेस्टकिट का उपयोग करने की कोशिश कर रहा हूं जिसके लिए मूल प्रमाणीकरण की आवश्यकता है।मैं RestKit 0.20.0 के साथ मूल प्रमाणीकरण कैसे सेट करूं?
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[JSNCategory class]];
[mapping addAttributeMappingsFromDictionary:@{
@"id": @"catId",
@"name": @"name"
}];
NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);
RKResponseDescriptor *responseDescriptor
= [RKResponseDescriptor responseDescriptorWithMapping:mapping
pathPattern:@"/api/v1/categories"
keyPath:nil
statusCodes:statusCodes];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
URLWithString:@"https://rest.example.com"]];
RKObjectRequestOperation *operation
= [[RKObjectRequestOperation alloc] initWithRequest:request
responseDescriptors:@[responseDescriptor]];
[operation setCompletionBlockWithSuccess:
^(RKObjectRequestOperation *operation, RKMappingResult *result) {
JSNCategory *cat = [result firstObject];
NSLog(@"Mapped the category: %@", cat);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Failed with error: %@", [error localizedDescription]);
}];
उत्कृष्ट, एक आकर्षण काम करता है। –
ठीक @ ब्रेट्रयान, लेकिन आप RKObjectManager का उपयोग नहीं कर रहे हैं, तो आपने यह कैसे किया? – jturolla
मुझसे वही टिप्पणी। ऑब्जेक्ट प्रबंधक को कॉल में कैसे उपयोग किया जाता है? – nimbusgb