0

我遵循了几个使用 NSFetchedResultsController 类来检索和显示数据以在 UITableView 中显示的教程。如果我只是想在一个简单的 UIViewController 上的文本框中显示我的 JSON 结果集,该怎么办?有没有人有一个例子如何做到这一点?以下是我的代码片段;

// Request Object with json paramaters
RequestInquiry *requestInquiry = [[RequestInquiry alloc] init];
requestInquiry.docType = @"T";
//requestInquiry.documentNum = @"999999999";
requestInquiry.documentNum = self.strTicketNum;
requestInquiry.clientAccount = @"6";
requestInquiry.clientCode = @"02";
requestInquiry.token = @"f1234XFASF43434";
requestInquiry.requestType = @"submit";
requestInquiry.userId = @"XXXX";
requestInquiry.class1 = @"class com.rest.client.JsonRequest";


[[RKObjectManager sharedManager] postObject:requestInquiry path:@"/RestIVR/restservices/ticketservices/jinquiry" parameters:nil success:nil failure:^(RKObjectRequestOperation *operation, NSError *error) {

    NSLog(@"Error: %@",error);

}];
4

1 回答 1

0
- (void)callRemoteServiceWithPath: (NSString *)path postObject: (id)object andParameters: (NSString *)params withBlock:(void (^)(id ))block {
RKObjectManager *manager = [[MFRestKit sharedDataManager] objectManager];
NSData *postData  = [params dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:baseUrl];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path relativeToURL:url]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];

[AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
RKManagedObjectRequestOperation *operation = [manager managedObjectRequestOperationWithRequest:request managedObjectContext:manager.managedObjectStore.persistentStoreManagedObjectContext success:^(RKObjectRequestOperation *operation1, RKMappingResult *mappingResult) {
     block ([mappingResult array]);

} failure:^(RKObjectRequestOperation *operation1, NSError *error) {
    RKLogDebug(@"Failure %@",error.debugDescription);
    block (error);
}];
[manager enqueueObjectRequestOperation:operation];
}
于 2013-09-23T12:04:24.707 回答