From 90c3ab7f15e4918f01eec434d47af8cb0b698219 Mon Sep 17 00:00:00 2001 From: Ben Scheirman Date: Thu, 29 Mar 2012 08:19:39 -0500 Subject: [PATCH] Finished sample for episode 9 --- .../Bookmarks.xcodeproj/project.pbxproj | 311 +++++++++++++++ .../Bookmarks/AddBookmarkViewController.h | 32 ++ .../Bookmarks/AddBookmarkViewController.m | 87 ++++ .../Bookmarks/AddBookmarkViewController.xib | 375 ++++++++++++++++++ .../Bookmarks/Bookmarks/AppDelegate.h | 19 + .../Bookmarks/Bookmarks/AppDelegate.m | 59 +++ .../Bookmarks/Bookmarks/Bookmark.h | 16 + .../Bookmarks/Bookmarks/Bookmark.m | 32 ++ .../Bookmarks/Bookmarks/BookmarkManager.h | 22 + .../Bookmarks/Bookmarks/BookmarkManager.m | 62 +++ .../Bookmarks/Bookmarks/Bookmarks-Info.plist | 38 ++ .../Bookmarks/Bookmarks/Bookmarks-Prefix.pch | 14 + .../Bookmarks/Bookmarks/MyUtility.h | 15 + .../Bookmarks/Bookmarks/MyUtility.m | 17 + .../Bookmarks/Bookmarks/ViewController.h | 14 + .../Bookmarks/Bookmarks/ViewController.m | 69 ++++ .../Bookmarks/en.lproj/InfoPlist.strings | 2 + .../Bookmarks/en.lproj/ViewController.xib | 143 +++++++ .../Bookmarks/Bookmarks/main.m | 18 + 19 files changed, 1345 insertions(+) create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks.xcodeproj/project.pbxproj create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.h create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.m create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.xib create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.h create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.m create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.h create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.m create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.h create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.m create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Info.plist create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Prefix.pch create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.h create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.m create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.h create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.m create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/InfoPlist.strings create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/ViewController.xib create mode 100644 009-automatic-reference-counting/Bookmarks/Bookmarks/main.m diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks.xcodeproj/project.pbxproj b/009-automatic-reference-counting/Bookmarks/Bookmarks.xcodeproj/project.pbxproj new file mode 100644 index 0000000..797a6f2 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks.xcodeproj/project.pbxproj @@ -0,0 +1,311 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + B5B70C3B151FCF3900B8BBA7 /* MyUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B70C3A151FCF3900B8BBA7 /* MyUtility.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5C41A2E150D3C74004D3CD2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5C41A2D150D3C74004D3CD2 /* UIKit.framework */; }; + B5C41A30150D3C74004D3CD2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5C41A2F150D3C74004D3CD2 /* Foundation.framework */; }; + B5C41A32150D3C74004D3CD2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5C41A31150D3C74004D3CD2 /* CoreGraphics.framework */; }; + B5C41A38150D3C74004D3CD2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B5C41A36150D3C74004D3CD2 /* InfoPlist.strings */; }; + B5C41A3A150D3C74004D3CD2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C41A39150D3C74004D3CD2 /* main.m */; }; + B5C41A3E150D3C74004D3CD2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C41A3D150D3C74004D3CD2 /* AppDelegate.m */; }; + B5C41A41150D3C74004D3CD2 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C41A40150D3C74004D3CD2 /* ViewController.m */; }; + B5C41A44150D3C74004D3CD2 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5C41A42150D3C74004D3CD2 /* ViewController.xib */; }; + B5C41A4C150D3D12004D3CD2 /* BookmarkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C41A4B150D3D12004D3CD2 /* BookmarkManager.m */; }; + B5C41A50150D7A44004D3CD2 /* AddBookmarkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C41A4E150D7A44004D3CD2 /* AddBookmarkViewController.m */; }; + B5C41A51150D7A44004D3CD2 /* AddBookmarkViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5C41A4F150D7A44004D3CD2 /* AddBookmarkViewController.xib */; }; + B5D5F3F1150DB76300A2596F /* Bookmark.m in Sources */ = {isa = PBXBuildFile; fileRef = B5D5F3F0150DB76300A2596F /* Bookmark.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B5B70C39151FCF3900B8BBA7 /* MyUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyUtility.h; sourceTree = ""; }; + B5B70C3A151FCF3900B8BBA7 /* MyUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyUtility.m; sourceTree = ""; }; + B5C41A29150D3C74004D3CD2 /* Bookmarks.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Bookmarks.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B5C41A2D150D3C74004D3CD2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + B5C41A2F150D3C74004D3CD2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + B5C41A31150D3C74004D3CD2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + B5C41A35150D3C74004D3CD2 /* Bookmarks-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Bookmarks-Info.plist"; sourceTree = ""; }; + B5C41A37150D3C74004D3CD2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + B5C41A39150D3C74004D3CD2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + B5C41A3B150D3C74004D3CD2 /* Bookmarks-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bookmarks-Prefix.pch"; sourceTree = ""; }; + B5C41A3C150D3C74004D3CD2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + B5C41A3D150D3C74004D3CD2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + B5C41A3F150D3C74004D3CD2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + B5C41A40150D3C74004D3CD2 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + B5C41A43150D3C74004D3CD2 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController.xib; sourceTree = ""; }; + B5C41A4A150D3D12004D3CD2 /* BookmarkManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookmarkManager.h; sourceTree = ""; }; + B5C41A4B150D3D12004D3CD2 /* BookmarkManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookmarkManager.m; sourceTree = ""; }; + B5C41A4D150D7A44004D3CD2 /* AddBookmarkViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddBookmarkViewController.h; sourceTree = ""; }; + B5C41A4E150D7A44004D3CD2 /* AddBookmarkViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddBookmarkViewController.m; sourceTree = ""; }; + B5C41A4F150D7A44004D3CD2 /* AddBookmarkViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AddBookmarkViewController.xib; sourceTree = ""; }; + B5D5F3EF150DB76300A2596F /* Bookmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bookmark.h; sourceTree = ""; }; + B5D5F3F0150DB76300A2596F /* Bookmark.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bookmark.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B5C41A26150D3C74004D3CD2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + B5C41A2E150D3C74004D3CD2 /* UIKit.framework in Frameworks */, + B5C41A30150D3C74004D3CD2 /* Foundation.framework in Frameworks */, + B5C41A32150D3C74004D3CD2 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B5C41A1E150D3C74004D3CD2 = { + isa = PBXGroup; + children = ( + B5C41A33150D3C74004D3CD2 /* Bookmarks */, + B5C41A2C150D3C74004D3CD2 /* Frameworks */, + B5C41A2A150D3C74004D3CD2 /* Products */, + ); + sourceTree = ""; + }; + B5C41A2A150D3C74004D3CD2 /* Products */ = { + isa = PBXGroup; + children = ( + B5C41A29150D3C74004D3CD2 /* Bookmarks.app */, + ); + name = Products; + sourceTree = ""; + }; + B5C41A2C150D3C74004D3CD2 /* Frameworks */ = { + isa = PBXGroup; + children = ( + B5C41A2D150D3C74004D3CD2 /* UIKit.framework */, + B5C41A2F150D3C74004D3CD2 /* Foundation.framework */, + B5C41A31150D3C74004D3CD2 /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + B5C41A33150D3C74004D3CD2 /* Bookmarks */ = { + isa = PBXGroup; + children = ( + B5C41A4A150D3D12004D3CD2 /* BookmarkManager.h */, + B5C41A4B150D3D12004D3CD2 /* BookmarkManager.m */, + B5C41A3C150D3C74004D3CD2 /* AppDelegate.h */, + B5C41A3D150D3C74004D3CD2 /* AppDelegate.m */, + B5C41A3F150D3C74004D3CD2 /* ViewController.h */, + B5C41A40150D3C74004D3CD2 /* ViewController.m */, + B5C41A42150D3C74004D3CD2 /* ViewController.xib */, + B5C41A4D150D7A44004D3CD2 /* AddBookmarkViewController.h */, + B5C41A4E150D7A44004D3CD2 /* AddBookmarkViewController.m */, + B5C41A4F150D7A44004D3CD2 /* AddBookmarkViewController.xib */, + B5C41A34150D3C74004D3CD2 /* Supporting Files */, + B5D5F3EF150DB76300A2596F /* Bookmark.h */, + B5D5F3F0150DB76300A2596F /* Bookmark.m */, + B5B70C39151FCF3900B8BBA7 /* MyUtility.h */, + B5B70C3A151FCF3900B8BBA7 /* MyUtility.m */, + ); + path = Bookmarks; + sourceTree = ""; + }; + B5C41A34150D3C74004D3CD2 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + B5C41A35150D3C74004D3CD2 /* Bookmarks-Info.plist */, + B5C41A36150D3C74004D3CD2 /* InfoPlist.strings */, + B5C41A39150D3C74004D3CD2 /* main.m */, + B5C41A3B150D3C74004D3CD2 /* Bookmarks-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B5C41A28150D3C74004D3CD2 /* Bookmarks */ = { + isa = PBXNativeTarget; + buildConfigurationList = B5C41A47150D3C74004D3CD2 /* Build configuration list for PBXNativeTarget "Bookmarks" */; + buildPhases = ( + B5C41A25150D3C74004D3CD2 /* Sources */, + B5C41A26150D3C74004D3CD2 /* Frameworks */, + B5C41A27150D3C74004D3CD2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Bookmarks; + productName = Bookmarks; + productReference = B5C41A29150D3C74004D3CD2 /* Bookmarks.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B5C41A20150D3C74004D3CD2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + ORGANIZATIONNAME = NSScreencast; + }; + buildConfigurationList = B5C41A23150D3C74004D3CD2 /* Build configuration list for PBXProject "Bookmarks" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = B5C41A1E150D3C74004D3CD2; + productRefGroup = B5C41A2A150D3C74004D3CD2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B5C41A28150D3C74004D3CD2 /* Bookmarks */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B5C41A27150D3C74004D3CD2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B5C41A38150D3C74004D3CD2 /* InfoPlist.strings in Resources */, + B5C41A44150D3C74004D3CD2 /* ViewController.xib in Resources */, + B5C41A51150D7A44004D3CD2 /* AddBookmarkViewController.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B5C41A25150D3C74004D3CD2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B5C41A3A150D3C74004D3CD2 /* main.m in Sources */, + B5C41A3E150D3C74004D3CD2 /* AppDelegate.m in Sources */, + B5C41A41150D3C74004D3CD2 /* ViewController.m in Sources */, + B5C41A4C150D3D12004D3CD2 /* BookmarkManager.m in Sources */, + B5C41A50150D7A44004D3CD2 /* AddBookmarkViewController.m in Sources */, + B5D5F3F1150DB76300A2596F /* Bookmark.m in Sources */, + B5B70C3B151FCF3900B8BBA7 /* MyUtility.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + B5C41A36150D3C74004D3CD2 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + B5C41A37150D3C74004D3CD2 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + B5C41A42150D3C74004D3CD2 /* ViewController.xib */ = { + isa = PBXVariantGroup; + children = ( + B5C41A43150D3C74004D3CD2 /* en */, + ); + name = ViewController.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + B5C41A45150D3C74004D3CD2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + }; + name = Debug; + }; + B5C41A46150D3C74004D3CD2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + B5C41A48150D3C74004D3CD2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Bookmarks/Bookmarks-Prefix.pch"; + INFOPLIST_FILE = "Bookmarks/Bookmarks-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + B5C41A49150D3C74004D3CD2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Bookmarks/Bookmarks-Prefix.pch"; + INFOPLIST_FILE = "Bookmarks/Bookmarks-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B5C41A23150D3C74004D3CD2 /* Build configuration list for PBXProject "Bookmarks" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B5C41A45150D3C74004D3CD2 /* Debug */, + B5C41A46150D3C74004D3CD2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B5C41A47150D3C74004D3CD2 /* Build configuration list for PBXNativeTarget "Bookmarks" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B5C41A48150D3C74004D3CD2 /* Debug */, + B5C41A49150D3C74004D3CD2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B5C41A20150D3C74004D3CD2 /* Project object */; +} diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.h b/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.h new file mode 100644 index 0000000..c9710d8 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.h @@ -0,0 +1,32 @@ +// +// AddBookmarkViewController.h +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import + +@protocol AddBookmarkDelegate; + +@interface AddBookmarkViewController : UIViewController + +@property (nonatomic, unsafe_unretained) id delegate; +@property (nonatomic) IBOutlet UITextField *labelTextField; +@property (nonatomic) IBOutlet UITextField *urlTextField; + + +@end + +@protocol AddBookmarkDelegate + +@required + +- (void)addBookmarkViewController:(AddBookmarkViewController *)viewController + didSaveBookmarkWithLabel:(NSString *)label + url:(NSString *)url; + +- (void)addBookmarkViewControllerDidCancel:(AddBookmarkViewController *)viewController; + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.m b/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.m new file mode 100644 index 0000000..9eb51be --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.m @@ -0,0 +1,87 @@ +// +// AddBookmarkViewController.m +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import "AddBookmarkViewController.h" + +@interface AddBookmarkViewController () + +@end + +@implementation AddBookmarkViewController + +@synthesize delegate = _delegate; +@synthesize labelTextField = _labelTextField; +@synthesize urlTextField = _urlTextField; + +- (id)init { + self = [super initWithNibName:@"AddBookmarkViewController" bundle:nil]; + if (self) { + } + return self; +} + + +- (UIBarButtonItem *)cancelButton { + return [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(onCancel:)]; +} + +- (UIBarButtonItem *)saveButton { + return [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave + target:self + action:@selector(onSave:)]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.title = @"Add a Bookmark"; + + self.navigationItem.leftBarButtonItem = [self cancelButton]; + self.navigationItem.rightBarButtonItem = [self saveButton]; + + [self.labelTextField becomeFirstResponder]; +} + +- (void)viewDidUnload { + [super viewDidUnload]; + + self.labelTextField = nil; + self.urlTextField = nil; +} + +- (void)onSave:(id)sender { + NSString *label = self.labelTextField.text; + NSString *url = self.urlTextField.text; + + if ([label length] == 0 || [url length] == 0) { + return; + } + + [self.delegate addBookmarkViewController:self + didSaveBookmarkWithLabel:self.labelTextField.text + url:self.urlTextField.text]; +} + +- (void)onCancel:(id)sender { + [self.delegate addBookmarkViewControllerDidCancel:self]; +} + +#pragma mark - UITextFieldDelegate methods + +- (BOOL)textFieldShouldReturn:(UITextField *)textField { + if (textField == self.labelTextField) { + [self.urlTextField becomeFirstResponder]; + } else { + [self onSave:textField]; + } + return NO; +} + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.xib b/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.xib new file mode 100644 index 0000000..3d39426 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/AddBookmarkViewController.xib @@ -0,0 +1,375 @@ + + + + 1296 + 11D50d + 2182 + 1138.32 + 568.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1179 + + + IBUILabel + IBUIView + IBUITextField + IBProxyObject + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + + + + 292 + {{20, 54}, {280, 31}} + + + + _NS:9 + NO + YES + IBCocoaTouchFramework + 0 + + 3 + + 3 + MAA + + 2 + + + YES + 17 + + IBCocoaTouchFramework + + + 1 + 14 + + + Helvetica + 14 + 16 + + + + + 292 + {{20, 25}, {42, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + Label + + 1 + MCAwIDAAA + + + 0 + 10 + + 1 + 17 + + + Helvetica + 17 + 16 + + + + + 292 + {{20, 139}, {280, 31}} + + + _NS:9 + NO + YES + IBCocoaTouchFramework + 0 + + 3 + + 3 + MAA + + + YES + 17 + + 3 + 9 + YES + IBCocoaTouchFramework + + + + + + + 292 + {{20, 110}, {42, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + URL + + + 0 + 10 + + + + + {{0, 64}, {320, 416}} + + + + + 10 + + 549453824 + {512, 1} + + + + + + TU0AKgAACAjFzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ +y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ +xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ +xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ +xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ +xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ +xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ +y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ +y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ +xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ +xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ +xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ +xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ +xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ +y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ +y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ +xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ +xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ +xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ +xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ +xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ +y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ +y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ +xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ +xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ +xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ +xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ +xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ +y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ +y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ +xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ +xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ +xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ +xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ +xczS/8vS2P/L0tj/xczU/wANAQAAAwAAAAECAAAAAQEAAwAAAAEAAQAAAQIAAwAAAAQAAAiqAQMAAwAA +AAEAAQAAAQYAAwAAAAEAAgAAAREABAAAAAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEABAAAARYAAwAA +AAEAAQAAARcABAAAAAEAAAgAARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAQAAAiyAAAAAAAI +AAgACAAIAAEAAQABAAE + + + + + + 3 + MCAwAA + + + groupTableViewBackgroundColor + + + + NO + + IBCocoaTouchFramework + + + + + + + view + + + + 3 + + + + labelTextField + + + + 10 + + + + urlTextField + + + + 11 + + + + delegate + + + + 14 + + + + delegate + + + + 13 + + + + + + 0 + + + + + + 1 + + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + + + AddBookmarkViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 14 + + + + + AddBookmarkViewController + UIViewController + + UITextField + UITextField + + + + labelTextField + UITextField + + + urlTextField + UITextField + + + + IBProjectSource + ./Classes/AddBookmarkViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + YES + 3 + 1179 + + diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.h b/009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.h new file mode 100644 index 0000000..fab7ba4 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.h @@ -0,0 +1,19 @@ +// +// AppDelegate.h +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import + +@class ViewController; + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@property (strong, nonatomic) ViewController *viewController; + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.m b/009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.m new file mode 100644 index 0000000..be61a79 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/AppDelegate.m @@ -0,0 +1,59 @@ +// +// AppDelegate.m +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. 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]; + + UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; + self.window.rootViewController = navController; + + [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 diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.h b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.h new file mode 100644 index 0000000..d61a859 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.h @@ -0,0 +1,16 @@ +// +// Bookmark.h +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import + +@interface Bookmark : NSObject + +@property (nonatomic, copy) NSString *label; +@property (nonatomic, copy) NSString *url; + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.m b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.m new file mode 100644 index 0000000..6e9f1f3 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmark.m @@ -0,0 +1,32 @@ +// +// Bookmark.m +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import "Bookmark.h" + +@implementation Bookmark + +@synthesize label = _label; +@synthesize url = _url; + +- (id)initWithCoder:(NSCoder *)aDecoder { + self = [super init]; + if (self) { + self.label = [aDecoder decodeObjectForKey:@"label"]; + self.url = [aDecoder decodeObjectForKey:@"url"]; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:self.label forKey:@"label"]; + [aCoder encodeObject:self.url forKey:@"url"]; +} + + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.h b/009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.h new file mode 100644 index 0000000..0dd74f9 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.h @@ -0,0 +1,22 @@ +// +// BookmarkManager.h +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import +#import "Bookmark.h" + +@interface BookmarkManager : NSObject { + NSString *_path; + NSMutableArray *_bookmarks; +} + ++ (id)sharedManager; + +- (NSArray *)bookmarks; +- (void)addBookmark:(Bookmark *)bookmark; + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.m b/009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.m new file mode 100644 index 0000000..cc3b939 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/BookmarkManager.m @@ -0,0 +1,62 @@ +// +// BookmarkManager.m +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import "BookmarkManager.h" + +@implementation BookmarkManager + ++ (id)sharedManager { + static BookmarkManager *__instance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + __instance = [[BookmarkManager alloc] init]; + }); + + return __instance; +} + +- (id)init { + self = [super init]; + if (self) { + NSString *documentsDirectory = nil; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + documentsDirectory = [paths objectAtIndex:0]; + _path = [documentsDirectory stringByAppendingPathComponent:@"bookmarks.dat"]; + NSLog(@"Saving bookmarks in %@", _path); + } + + return self; +} + + +- (void)loadBookmarks { + _bookmarks = [NSKeyedUnarchiver unarchiveObjectWithFile:_path]; + if (!_bookmarks) { + _bookmarks = [NSMutableArray array]; + } +} + +- (NSArray *)bookmarks { + if (!_bookmarks) { + [self loadBookmarks]; + } + return _bookmarks; +} + +- (void)addBookmark:(Bookmark *)bookmark { + if (!_bookmarks) + [self loadBookmarks]; + + NSLog(@"Adding bookmark [name: %@] [url: %@]", bookmark.label, bookmark.url); + + [_bookmarks addObject:bookmark]; + + [NSKeyedArchiver archiveRootObject:_bookmarks toFile:_path]; +} + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Info.plist b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Info.plist new file mode 100644 index 0000000..ef4d445 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.nsscreencast.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Prefix.pch b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Prefix.pch new file mode 100644 index 0000000..f4190b3 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/Bookmarks-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'Bookmarks' target in the 'Bookmarks' project +// + +#import + +#ifndef __IPHONE_4_0 +#warning "This project uses features only available in iOS SDK 4.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.h b/009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.h new file mode 100644 index 0000000..996d531 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.h @@ -0,0 +1,15 @@ +// +// MyUtility.h +// Bookmarks +// +// Created by Ben Scheirman on 3/25/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import + +@interface MyUtility : NSObject + ++ (NSNumber *)myNumber; + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.m b/009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.m new file mode 100644 index 0000000..22826ef --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/MyUtility.m @@ -0,0 +1,17 @@ +// +// MyUtility.m +// Bookmarks +// +// Created by Ben Scheirman on 3/25/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import "MyUtility.h" + +@implementation MyUtility + ++ (NSNumber *)myNumber { + return [[[NSNumber alloc] initWithInt:15] autorelease]; +} + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.h b/009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.h new file mode 100644 index 0000000..331b338 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.h @@ -0,0 +1,14 @@ +// +// ViewController.h +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import +#import "AddBookmarkViewController.h" + +@interface ViewController : UITableViewController + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.m b/009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.m new file mode 100644 index 0000000..700f59b --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/ViewController.m @@ -0,0 +1,69 @@ +// +// ViewController.m +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import "ViewController.h" +#import "BookmarkManager.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.title = @"Bookmarks"; + id addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd + target:self + action:@selector(onAdd:)]; + self.navigationItem.rightBarButtonItem = addButton; +} + +- (void)onAdd:(id)sender { + AddBookmarkViewController *addController = [[AddBookmarkViewController alloc] init]; + addController.delegate = self; + [self.navigationController pushViewController:addController animated:YES]; +} + +#pragma mark - AddBookmarkDelegate methods + +- (void)addBookmarkViewControllerDidCancel:(AddBookmarkViewController *)viewController { + [self.navigationController popViewControllerAnimated:YES]; +} + +- (void)addBookmarkViewController:(AddBookmarkViewController *)viewController didSaveBookmarkWithLabel:(NSString *)label url:(NSString *)url { + Bookmark *bookmark = [[Bookmark alloc] init]; + bookmark.label = label; + bookmark.url = url; + + [[BookmarkManager sharedManager] addBookmark:bookmark]; + [self.tableView reloadData]; + [self.navigationController popViewControllerAnimated:YES]; +} + +#pragma mark - UITableViewDatasource methods + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return [[[BookmarkManager sharedManager] bookmarks] count]; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *identifier = @"cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; + if (!cell) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier]; + } + Bookmark *bookmark = [[[BookmarkManager sharedManager] bookmarks] objectAtIndex:indexPath.row]; + cell.textLabel.text = bookmark.label; + cell.detailTextLabel.text = bookmark.url; + + return cell; +} + +@end diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/InfoPlist.strings b/009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/ViewController.xib b/009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/ViewController.xib new file mode 100644 index 0000000..35d4611 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/en.lproj/ViewController.xib @@ -0,0 +1,143 @@ + + + + 1296 + 11D50d + 2182 + 1138.32 + 568.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1179 + + + IBProxyObject + IBUITableView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {320, 460} + + + _NS:9 + + 3 + MQA + + YES + IBCocoaTouchFramework + YES + 1 + 0 + YES + 44 + 22 + 22 + + + + + + + view + + + + 9 + + + + dataSource + + + + 10 + + + + delegate + + + + 11 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 8 + + + + + + + ViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 11 + + + + + ViewController + UITableViewController + + IBProjectSource + ./Classes/ViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + YES + 3 + 1179 + + diff --git a/009-automatic-reference-counting/Bookmarks/Bookmarks/main.m b/009-automatic-reference-counting/Bookmarks/Bookmarks/main.m new file mode 100644 index 0000000..60edfe9 --- /dev/null +++ b/009-automatic-reference-counting/Bookmarks/Bookmarks/main.m @@ -0,0 +1,18 @@ +// +// main.m +// Bookmarks +// +// Created by Ben Scheirman on 3/11/12. +// Copyright (c) 2012 NSScreencast. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}