Permalink
Browse files

Updated to version 1.0.1

  • Loading branch information...
1 parent e7b5134 commit 45f2e70f4f70021d0c52e3fd2d06e70e70943edd Nick Lockwood committed Feb 11, 2012
@@ -1,12 +1,13 @@
//
// CountryPicker.h
//
-// Version 1.0
+// Version 1.0.1
//
// Created by Nick Lockwood on 25/04/2011.
-// Copyright 2011 Charcoal Design. All rights reserved.
+// Copyright 2011 Charcoal Design
//
-// Get the latest version of CountryPicker from either of these locations:
+// Distributed under the permissive zlib License
+// Get the latest version from either of these locations:
//
// http://charcoaldesign.co.uk/source/cocoa#countrypicker
// https://github.com/nicklockwood/CountryPicker
@@ -35,6 +36,61 @@
// 3. This notice may not be removed or altered from any source distribution.
//
+//
+// ARC Helper
+//
+// Version 1.2
+//
+// Created by Nick Lockwood on 05/01/2012.
+// Charcoal Design Charcoal Design
+//
+// Distributed under the permissive zlib License
+// Get the latest version from here:
+//
+// https://gist.github.com/1563325
+//
+
+#ifndef AH_RETAIN
+#if __has_feature(objc_arc)
+#define AH_RETAIN(x) x
+#define AH_RELEASE(x)
+#define AH_AUTORELEASE(x) x
+#define AH_SUPER_DEALLOC
+#else
+#define __AH_WEAK
+#define AH_WEAK assign
+#define AH_RETAIN(x) [x retain]
+#define AH_RELEASE(x) [x release]
+#define AH_AUTORELEASE(x) [x autorelease]
+#define AH_SUPER_DEALLOC [super dealloc]
+#endif
+#endif
+
+// Weak reference support
+
+#ifndef AH_WEAK
+#if defined __IPHONE_OS_VERSION_MIN_REQUIRED
+#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_4_3
+#define __AH_WEAK __weak
+#define AH_WEAK weak
+#else
+#define __AH_WEAK __unsafe_unretained
+#define AH_WEAK unsafe_unretained
+#endif
+#elif defined __MAC_OS_X_VERSION_MIN_REQUIRED
+#if __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_6
+#define __AH_WEAK __weak
+#define AH_WEAK weak
+#else
+#define __AH_WEAK __unsafe_unretained
+#define AH_WEAK unsafe_unretained
+#endif
+#endif
+#endif
+
+// ARC Helper ends
+
+
#import <Foundation/Foundation.h>
@@ -55,7 +111,7 @@
+ (NSDictionary *)countryNamesByCode;
+ (NSDictionary *)countryCodesByName;
-@property (nonatomic, assign) id<CountryPickerDelegate> delegate;
+@property (nonatomic, AH_WEAK) id<CountryPickerDelegate> delegate;
@property (nonatomic, copy) NSString *selectedCountryName;
@property (nonatomic, copy) NSString *selectedCountryCode;
@@ -1,12 +1,13 @@
//
// CountryPicker.m
//
-// Version 1.0
+// Version 1.0.1
//
// Created by Nick Lockwood on 25/04/2011.
-// Copyright 2011 Charcoal Design. All rights reserved.
+// Copyright 2011 Charcoal Design
//
-// Get the latest version of CountryPicker from either of these locations:
+// Distributed under the permissive zlib License
+// Get the latest version from either of these locations:
//
// http://charcoaldesign.co.uk/source/cocoa#countrypicker
// https://github.com/nicklockwood/CountryPicker
@@ -65,7 +66,7 @@ + (void)initialize
countryCodesByName = [codesByName copy];
NSArray *names = [countryNamesByCode allValues];
- countryNames = [[names sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] retain];
+ countryNames = AH_RETAIN([names sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]);
NSMutableArray *codes = [NSMutableArray arrayWithCapacity:[names count]];
for (NSString *name in countryNames)
@@ -176,13 +177,13 @@ - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forC
{
if (!view)
{
- view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 30)] autorelease];
+ view = AH_AUTORELEASE([[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 30)]);
- UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(35, 3, 245, 24)] autorelease];
+ UILabel *label = AH_AUTORELEASE([[UILabel alloc] initWithFrame:CGRectMake(35, 3, 245, 24)]);
label.backgroundColor = [UIColor clearColor];
[view addSubview:label];
- UIImageView *flagView = [[[UIImageView alloc] initWithFrame:CGRectMake(3, 3, 24, 24)] autorelease];
+ UIImageView *flagView = AH_AUTORELEASE([[UIImageView alloc] initWithFrame:CGRectMake(3, 3, 24, 24)]);
flagView.contentMode = UIViewContentModeScaleToFill;
[view addSubview:flagView];
}
Oops, something went wrong.
@@ -0,0 +1,19 @@
+//
+// AppDelegate.h
+// CountryPickerDemo
+//
+// Created by Nick Lockwood on 11/02/2012.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class ViewController;
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (strong, nonatomic) ViewController *viewController;
+
+@end
@@ -0,0 +1,67 @@
+//
+// AppDelegate.m
+// CountryPickerDemo
+//
+// Created by Nick Lockwood on 11/02/2012.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+#import "ViewController.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+@synthesize viewController = _viewController;
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ // Override point for customization after application launch.
+ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
+ self.window.rootViewController = self.viewController;
+ [self.window makeKeyAndVisible];
+ 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
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFiles</key>
+ <array/>
+ <key>CFBundleIdentifier</key>
+ <string>com.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'CountryPickerDemo' target in the 'CountryPickerDemo' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_4_0
+#warning "This project uses features only available in iOS SDK 4.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
@@ -0,0 +1,17 @@
+//
+// ViewController.h
+// CountryPickerDemo
+//
+// Created by Nick Lockwood on 11/02/2012.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "CountryPicker.h"
+
+@interface ViewController : UIViewController <CountryPickerDelegate>
+
+@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
+@property (nonatomic, strong) IBOutlet UILabel *codeLabel;
+
+@end
@@ -0,0 +1,22 @@
+//
+// ViewController.m
+// CountryPickerDemo
+//
+// Created by Nick Lockwood on 11/02/2012.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "ViewController.h"
+
+@implementation ViewController
+
+@synthesize nameLabel;
+@synthesize codeLabel;
+
+- (void)countryPicker:(CountryPicker *)picker didSelectCountryWithName:(NSString *)name code:(NSString *)code
+{
+ nameLabel.text = name;
+ codeLabel.text = code;
+}
+
+@end
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
Oops, something went wrong.

0 comments on commit 45f2e70

Please sign in to comment.