Files
RestKit/Examples/RKCatalog/App/RootViewController.m
Blake Watters 2d281e60d3 Investigated issues surrounding inability to change HTTP AUTH credentials thoroughly. fixes #250, #237, #127
These issues has been open for some time. I have added thorough unit test coverage
for scenarios of mutating the HTTP AUTH credentials on the RKClient and on individual
RKRequest instances. Everything seems to work fine.

Also added RKAuthenticationExample to RKCatalog for testing. Needs to be updated with
support for using OAuth.
2011-09-27 23:59:06 -04:00

79 lines
2.6 KiB
Objective-C

//
// RootViewController.m
// RKCatalog
//
// Created by Blake Watters on 4/21/11.
// Copyright 2011 Two Toasters. All rights reserved.
//
#import <RestKit/RestKit.h>
#import "RootViewController.h"
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
_exampleTableItems = [[NSArray alloc] initWithObjects:
@"RKAuthenticationExample",
@"RKParamsExample",
@"RKRequestQueueExample",
@"RKReachabilityExample",
@"RKBackgroundRequestExample",
@"RKKeyValueMappingExample",
@"RKRelationshipMappingExample",
@"RKCoreDataExample",
nil];
}
- (void)dealloc {
[_exampleTableItems release];
[super dealloc];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_exampleTableItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"RKCatalogCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSString* exampleName = [_exampleTableItems objectAtIndex:indexPath.row];
cell.textLabel.text = exampleName;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Clear the singleton instances to isolate the examples
[RKClient setSharedClient:nil];
[RKObjectManager setSharedManager:nil];
NSString* exampleName = [_exampleTableItems objectAtIndex:indexPath.row];
Class exampleClass = NSClassFromString(exampleName);
UIViewController* exampleController = [[exampleClass alloc] initWithNibName:exampleName bundle:nil];
if (exampleController) {
[self.navigationController pushViewController:exampleController animated:YES];
if (exampleController.title == nil) {
exampleController.title = exampleName;
}
[exampleController release];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end