Skip to content

Commit

Permalink
Updated to version 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Dec 18, 2012
1 parent 1323155 commit bf3124f
Show file tree
Hide file tree
Showing 25 changed files with 151 additions and 247 deletions.
11 changes: 11 additions & 0 deletions Examples/BasicAuth/BasicAuth.xcodeproj/project.pbxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = { objects = {


/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
01FDC29916811842001E49A6 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 01FDC29816811842001E49A6 /* Default-568h@2x.png */; };
B22B852E156528300001A7C2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22B852D156528300001A7C2 /* UIKit.framework */; }; B22B852E156528300001A7C2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22B852D156528300001A7C2 /* UIKit.framework */; };
B22B8530156528300001A7C2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22B852F156528300001A7C2 /* Foundation.framework */; }; B22B8530156528300001A7C2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22B852F156528300001A7C2 /* Foundation.framework */; };
B22B8532156528300001A7C2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22B8531156528300001A7C2 /* CoreGraphics.framework */; }; B22B8532156528300001A7C2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22B8531156528300001A7C2 /* CoreGraphics.framework */; };
Expand All @@ -19,6 +20,7 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */


/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
01FDC29816811842001E49A6 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
B22B8529156528300001A7C2 /* BasicAuth.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BasicAuth.app; sourceTree = BUILT_PRODUCTS_DIR; }; B22B8529156528300001A7C2 /* BasicAuth.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BasicAuth.app; sourceTree = BUILT_PRODUCTS_DIR; };
B22B852D156528300001A7C2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; B22B852D156528300001A7C2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
B22B852F156528300001A7C2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; B22B852F156528300001A7C2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -94,6 +96,7 @@
B22B8534156528300001A7C2 /* Supporting Files */ = { B22B8534156528300001A7C2 /* Supporting Files */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
01FDC29816811842001E49A6 /* Default-568h@2x.png */,
B22B8535156528300001A7C2 /* BasicAuth-Info.plist */, B22B8535156528300001A7C2 /* BasicAuth-Info.plist */,
B22B8536156528300001A7C2 /* InfoPlist.strings */, B22B8536156528300001A7C2 /* InfoPlist.strings */,
B22B8539156528300001A7C2 /* main.m */, B22B8539156528300001A7C2 /* main.m */,
Expand Down Expand Up @@ -164,6 +167,7 @@
files = ( files = (
B22B8538156528300001A7C2 /* InfoPlist.strings in Resources */, B22B8538156528300001A7C2 /* InfoPlist.strings in Resources */,
B22B8544156528300001A7C2 /* ViewController.xib in Resources */, B22B8544156528300001A7C2 /* ViewController.xib in Resources */,
01FDC29916811842001E49A6 /* Default-568h@2x.png in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down Expand Up @@ -209,6 +213,7 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_OBJCPP_ARC_ABI = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -219,11 +224,13 @@
"$(inherited)", "$(inherited)",
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1; IPHONEOS_DEPLOYMENT_TARGET = 5.1;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
name = Debug; name = Debug;
Expand All @@ -234,15 +241,18 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_OBJCPP_ARC_ABI = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1; IPHONEOS_DEPLOYMENT_TARGET = 5.1;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
Expand Down Expand Up @@ -289,6 +299,7 @@
B22B8549156528300001A7C2 /* Release */, B22B8549156528300001A7C2 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
}; };
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };
Expand Down
5 changes: 2 additions & 3 deletions Examples/BasicAuth/BasicAuth/AppDelegate.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@


@interface AppDelegate : UIResponder <UIApplicationDelegate> @interface AppDelegate : UIResponder <UIApplicationDelegate>


@property (strong, nonatomic) UIWindow *window; @property (nonatomic) UIWindow *window;

@property (nonatomic) ViewController *viewController;
@property (strong, nonatomic) ViewController *viewController;


@end @end
30 changes: 0 additions & 30 deletions Examples/BasicAuth/BasicAuth/AppDelegate.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@


@implementation AppDelegate @implementation AppDelegate


@synthesize window = _window;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
Expand All @@ -25,31 +22,4 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES; return YES;
} }


- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end @end
Binary file added Examples/BasicAuth/BasicAuth/Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Examples/BasicAuth/BasicAuth/ViewController.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@


@interface ViewController : UIViewController @interface ViewController : UIViewController


@property (nonatomic, strong) IBOutlet UIImageView *imageView; @property (nonatomic) IBOutlet UIImageView *imageView;


@end @end
15 changes: 6 additions & 9 deletions Examples/BasicAuth/BasicAuth/ViewController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@


@interface ViewController () <UIAlertViewDelegate> @interface ViewController () <UIAlertViewDelegate>


@property (nonatomic, strong) NSURLAuthenticationChallenge *challenge; @property (nonatomic) NSURLAuthenticationChallenge *challenge;


@end @end




@implementation ViewController @implementation ViewController


@synthesize imageView;
@synthesize challenge;

- (void)viewDidLoad - (void)viewDidLoad
{ {
[super viewDidLoad]; [super viewDidLoad];
Expand All @@ -32,9 +29,9 @@ - (void)viewDidLoad
RQOperation *operation = [RQOperation operationWithRequest:request]; RQOperation *operation = [RQOperation operationWithRequest:request];


//add auth handler //add auth handler
operation.authenticationChallengeHandler = ^(NSURLAuthenticationChallenge *_challenge) operation.authenticationChallengeHandler = ^(NSURLAuthenticationChallenge *challenge)
{ {
challenge = _challenge; _challenge = challenge;
[[[UIAlertView alloc] initWithTitle:@"Challenge Receiver" message:@"Send credentials?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Send", nil] show]; [[[UIAlertView alloc] initWithTitle:@"Challenge Receiver" message:@"Send credentials?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Send", nil] show];


}; };
Expand All @@ -49,7 +46,7 @@ - (void)viewDidLoad
else else
{ {
//set image //set image
imageView.image = [UIImage imageWithData:data]; _imageView.image = [UIImage imageWithData:data];
} }
}; };


Expand All @@ -62,7 +59,7 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)
if (buttonIndex == alertView.cancelButtonIndex) if (buttonIndex == alertView.cancelButtonIndex)
{ {
//don't send credentials //don't send credentials
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; [_challenge.sender continueWithoutCredentialForAuthenticationChallenge:_challenge];
} }
else else
{ {
Expand All @@ -71,7 +68,7 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)
password:@"test" password:@"test"
persistence:NSURLCredentialPersistenceNone]; persistence:NSURLCredentialPersistenceNone];
//send credential //send credential
[challenge.sender useCredential:credential forAuthenticationChallenge:challenge]; [_challenge.sender useCredential:credential forAuthenticationChallenge:_challenge];
} }
} }


Expand Down
4 changes: 2 additions & 2 deletions Examples/ImageLoader/Classes/ImageLoaderAppDelegate.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


@interface ImageLoaderAppDelegate : NSObject <UIApplicationDelegate> @interface ImageLoaderAppDelegate : NSObject <UIApplicationDelegate>


@property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, strong) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; @property (nonatomic, strong) IBOutlet UINavigationController *navigationController;


@end @end


12 changes: 0 additions & 12 deletions Examples/ImageLoader/Classes/ImageLoaderAppDelegate.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,24 +15,12 @@ @implementation ImageLoaderAppDelegate
@synthesize window; @synthesize window;
@synthesize navigationController; @synthesize navigationController;


#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
[window addSubview:[navigationController view]]; [window addSubview:[navigationController view]];
[window makeKeyAndVisible]; [window makeKeyAndVisible];
return YES; return YES;
} }


#pragma mark Memory management

- (void)dealloc
{
[navigationController release];
[window release];
[super dealloc];
}


@end @end


2 changes: 1 addition & 1 deletion Examples/ImageLoader/Classes/RootViewController.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@interface RootViewController : UITableViewController @interface RootViewController : UITableViewController


@property (nonatomic, retain) UIBarButtonItem *loadUnloadButton; @property (nonatomic, strong) UIBarButtonItem *loadUnloadButton;


- (IBAction)loadUnloadImages; - (IBAction)loadUnloadImages;


Expand Down
33 changes: 12 additions & 21 deletions Examples/ImageLoader/Classes/RootViewController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@


@interface RootViewController () @interface RootViewController ()


@property (nonatomic, retain) NSMutableArray *urlStrings; @property (nonatomic, strong) NSMutableArray *urlStrings;
@property (nonatomic, retain) NSMutableDictionary *images; @property (nonatomic, strong) NSMutableDictionary *images;


@end @end


Expand All @@ -30,10 +30,10 @@ - (void)viewDidLoad
{ {
[super viewDidLoad]; [super viewDidLoad];


self.loadUnloadButton = [[[UIBarButtonItem alloc] initWithTitle:@"Load" self.loadUnloadButton = [[UIBarButtonItem alloc] initWithTitle:@"Load"
style:UIBarButtonItemStylePlain style:UIBarButtonItemStylePlain
target:self target:self
action:@selector(loadUnloadImages)] autorelease]; action:@selector(loadUnloadImages)];


self.navigationItem.rightBarButtonItem = loadUnloadButton; self.navigationItem.rightBarButtonItem = loadUnloadButton;
self.navigationItem.title = @"Images"; self.navigationItem.title = @"Images";
Expand Down Expand Up @@ -99,20 +99,20 @@ - (void)loadUnloadImages
UIImage *image = [UIImage imageWithData:data]; UIImage *image = [UIImage imageWithData:data];
if (image) if (image)
{ {
[images setObject:image forKey:urlString]; images[urlString] = image;
} }
else else
{ {
//image error //image error
NSInteger index = [urlStrings indexOfObject:urlString]; NSInteger index = [urlStrings indexOfObject:urlString];
[urlStrings replaceObjectAtIndex:index withObject:@"Image was missing or corrupt"]; urlStrings[index] = @"Image was missing or corrupt";
} }
} }
else else
{ {
//loading error //loading error
NSInteger index = [urlStrings indexOfObject:urlString]; NSInteger index = [urlStrings indexOfObject:urlString];
[urlStrings replaceObjectAtIndex:index withObject:[error localizedDescription]]; urlStrings[index] = [error localizedDescription];
} }


//refresh view //refresh view
Expand All @@ -137,11 +137,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) if (cell == nil)
{ {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
} }


NSString *urlString = [urlStrings objectAtIndex:indexPath.row]; NSString *urlString = urlStrings[indexPath.row];
cell.imageView.image = [images objectForKey:urlString]; cell.imageView.image = images[urlString];
cell.textLabel.text = [urlString lastPathComponent]; cell.textLabel.text = [urlString lastPathComponent];


return cell; return cell;
Expand All @@ -155,15 +155,13 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
UIViewController *viewController = [[UIViewController alloc] init]; UIViewController *viewController = [[UIViewController alloc] init];


//set view //set view
NSString *urlString = [urlStrings objectAtIndex:indexPath.row]; NSString *urlString = urlStrings[indexPath.row];
UIImage *image = [images objectForKey:urlString]; UIImage *image = images[urlString];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
viewController.view = imageView; viewController.view = imageView;
[imageView release];


//pass the selected object to the new view controller. //pass the selected object to the new view controller.
[self.navigationController pushViewController:viewController animated:YES]; [self.navigationController pushViewController:viewController animated:YES];
[viewController release];
} }


#pragma mark Memory management #pragma mark Memory management
Expand All @@ -174,13 +172,6 @@ - (void)viewDidUnload
[super viewDidUnload]; [super viewDidUnload];
} }


- (void)dealloc
{
[loadUnloadButton release];
[urlStrings release];
[images release];
[super dealloc];
}




@end @end
Expand Down
Binary file added Examples/ImageLoader/Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bf3124f

Please sign in to comment.