Browse files

Project1 with working UIAlertView

  • Loading branch information...
1 parent e41480f commit 51288253876c0d693c17621a2536fc5500df97b9 @jungziege jungziege committed Dec 7, 2011
View
6 Example0/Example0/HBStringPrinter.h
@@ -12,12 +12,6 @@
@property (nonatomic, retain) NSString *stringToPrint;
-//The code below replicates the property above
-/*
-- (void)setStringToPrint: (NSString *)stringToPrint;
-- (NSString *)stringToPrint;
-*/
-
- (void)printString;
@end
View
4 Example0/Example0/HBStringPrinter.m
@@ -8,9 +8,7 @@
#import "HBStringPrinter.h"
-@implementation HBStringPrinter {
- NSString *_stringToPrint;
-}
+@implementation HBStringPrinter
@synthesize stringToPrint=_stringToPrint;
View
1 Example0/Example0/main.m
@@ -23,7 +23,6 @@ int main (int argc, const char * argv[])
[stringPrinter1 printString];
-
[stringPrinter1 release];
}
View
269 Project1/Project1.xcodeproj/project.pbxproj
@@ -0,0 +1,269 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 05E7711B1480545A00E7FD0E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05E7711A1480545A00E7FD0E /* UIKit.framework */; };
+ 05E7711D1480545A00E7FD0E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05E7711C1480545A00E7FD0E /* Foundation.framework */; };
+ 05E7711F1480545A00E7FD0E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05E7711E1480545A00E7FD0E /* CoreGraphics.framework */; };
+ 05E771251480545A00E7FD0E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 05E771231480545A00E7FD0E /* InfoPlist.strings */; };
+ 05E771271480545A00E7FD0E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E771261480545A00E7FD0E /* main.m */; };
+ 05E7712B1480545A00E7FD0E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E7712A1480545A00E7FD0E /* AppDelegate.m */; };
+ 05E7712E1480545A00E7FD0E /* ViewControllerWithAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E7712D1480545A00E7FD0E /* ViewControllerWithAlertView.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 05E771161480545A00E7FD0E /* Project1.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Project1.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 05E7711A1480545A00E7FD0E /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 05E7711C1480545A00E7FD0E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 05E7711E1480545A00E7FD0E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 05E771221480545A00E7FD0E /* Project1-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Project1-Info.plist"; sourceTree = "<group>"; };
+ 05E771241480545A00E7FD0E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 05E771261480545A00E7FD0E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 05E771281480545A00E7FD0E /* Project1-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Project1-Prefix.pch"; sourceTree = "<group>"; };
+ 05E771291480545A00E7FD0E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ 05E7712A1480545A00E7FD0E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ 05E7712C1480545A00E7FD0E /* ViewControllerWithAlertView.h */ = {isa = PBXFileReference; path = ViewControllerWithAlertView.h; sourceTree = "<group>"; };
+ 05E7712D1480545A00E7FD0E /* ViewControllerWithAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewControllerWithAlertView.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 05E771131480545A00E7FD0E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 05E7711B1480545A00E7FD0E /* UIKit.framework in Frameworks */,
+ 05E7711D1480545A00E7FD0E /* Foundation.framework in Frameworks */,
+ 05E7711F1480545A00E7FD0E /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 05E7710B1480545A00E7FD0E = {
+ isa = PBXGroup;
+ children = (
+ 05E771201480545A00E7FD0E /* Project1 */,
+ 05E771191480545A00E7FD0E /* Frameworks */,
+ 05E771171480545A00E7FD0E /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 05E771171480545A00E7FD0E /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 05E771161480545A00E7FD0E /* Project1.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 05E771191480545A00E7FD0E /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 05E7711A1480545A00E7FD0E /* UIKit.framework */,
+ 05E7711C1480545A00E7FD0E /* Foundation.framework */,
+ 05E7711E1480545A00E7FD0E /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 05E771201480545A00E7FD0E /* Project1 */ = {
+ isa = PBXGroup;
+ children = (
+ 05E771291480545A00E7FD0E /* AppDelegate.h */,
+ 05E7712A1480545A00E7FD0E /* AppDelegate.m */,
+ 05E7712C1480545A00E7FD0E /* ViewControllerWithAlertView.h */,
+ 05E7712D1480545A00E7FD0E /* ViewControllerWithAlertView.m */,
+ 05E771211480545A00E7FD0E /* Supporting Files */,
+ );
+ name = Project1;
+ path = "Project1-noNib";
+ sourceTree = "<group>";
+ };
+ 05E771211480545A00E7FD0E /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 05E771221480545A00E7FD0E /* Project1-Info.plist */,
+ 05E771231480545A00E7FD0E /* InfoPlist.strings */,
+ 05E771261480545A00E7FD0E /* main.m */,
+ 05E771281480545A00E7FD0E /* Project1-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 05E771151480545A00E7FD0E /* Project1 */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 05E771341480545A00E7FD0E /* Build configuration list for PBXNativeTarget "Project1" */;
+ buildPhases = (
+ 05E771121480545A00E7FD0E /* Sources */,
+ 05E771131480545A00E7FD0E /* Frameworks */,
+ 05E771141480545A00E7FD0E /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = Project1;
+ productName = "Project1-noNib";
+ productReference = 05E771161480545A00E7FD0E /* Project1.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 05E7710D1480545A00E7FD0E /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
+ buildConfigurationList = 05E771101480545A00E7FD0E /* Build configuration list for PBXProject "Project1" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 05E7710B1480545A00E7FD0E;
+ productRefGroup = 05E771171480545A00E7FD0E /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 05E771151480545A00E7FD0E /* Project1 */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 05E771141480545A00E7FD0E /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 05E771251480545A00E7FD0E /* InfoPlist.strings in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 05E771121480545A00E7FD0E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 05E771271480545A00E7FD0E /* main.m in Sources */,
+ 05E7712B1480545A00E7FD0E /* AppDelegate.m in Sources */,
+ 05E7712E1480545A00E7FD0E /* ViewControllerWithAlertView.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 05E771231480545A00E7FD0E /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 05E771241480545A00E7FD0E /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 05E771321480545A00E7FD0E /* 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_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 05E771331480545A00E7FD0E /* 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_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 05E771351480545A00E7FD0E /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "Project1-noNib/Project1-Prefix.pch";
+ INFOPLIST_FILE = "Project1-noNib/Project1-Info.plist";
+ PRODUCT_NAME = Project1;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 05E771361480545A00E7FD0E /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "Project1-noNib/Project1-Prefix.pch";
+ INFOPLIST_FILE = "Project1-noNib/Project1-Info.plist";
+ PRODUCT_NAME = Project1;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 05E771101480545A00E7FD0E /* Build configuration list for PBXProject "Project1" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 05E771321480545A00E7FD0E /* Debug */,
+ 05E771331480545A00E7FD0E /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 05E771341480545A00E7FD0E /* Build configuration list for PBXNativeTarget "Project1" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 05E771351480545A00E7FD0E /* Debug */,
+ 05E771361480545A00E7FD0E /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 05E7710D1480545A00E7FD0E /* Project object */;
+}
View
7 Project1/Project1.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:Project1.xcodeproj">
+ </FileRef>
+</Workspace>
View
19 Project1/Project1/AppDelegate.h
@@ -0,0 +1,19 @@
+//
+// AppDelegate.h
+// Project1-noNib
+//
+// Created by Ian Davis on 11/25/11.
+// Copyright (c) 2011 __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
View
35 Project1/Project1/AppDelegate.m
@@ -0,0 +1,35 @@
+//
+// AppDelegate.m
+// Project1-noNib
+//
+// Created by Ian Davis on 11/25/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+#import "ViewController.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+@synthesize viewController = _viewController;
+
+- (void)dealloc
+{
+ [_window release];
+ [_viewController release];
+ [super dealloc];
+}
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+ // Override point for customization after application launch.
+ self.viewController = [[[ViewController alloc] initWithNibName:nil bundle:nil] autorelease];
+ self.window.rootViewController = self.viewController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+@end
View
40 Project1/Project1/Project1-Info.plist
@@ -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>hackatberkeley.${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>
View
14 Project1/Project1/Project1-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'Project1-noNib' target in the 'Project1-noNib' 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
View
13 Project1/Project1/ViewControllerWithAlertView.h
@@ -0,0 +1,13 @@
+//
+// ViewControllerWithAlertView.h
+// Project1
+//
+// Created by Ian Davis on 11/25/11.
+// Copyright (c) 2011 hackers @ Berkeley. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ViewControllerWithAlertView : UIViewController <UIAlertViewDelegate>
+
+@end
View
66 Project1/Project1/ViewControllerWithAlertView.m
@@ -0,0 +1,66 @@
+//
+// ViewControllerWithAlertView.m
+// Project1
+//
+// Created by Ian Davis on 11/25/11.
+// Copyright (c) 2011 Hackers @ Berkeley. All rights reserved.
+//
+
+#import "ViewControllerWithAlertView.h"
+
+#define kCancelButtonTitle @"Done"
+#define kRepeatButtonTitle @"Repeat"
+
+#define kButtonHeight 40
+#define kButtonWidth 80
+
+@interface ViewControllerWithAlertView ()
+- (void)buttonPressed;
+- (void)showAlertViewWithMessage:(NSString *)message;
+@end
+
+@implementation ViewControllerWithAlertView
+
+- (void)loadView {
+ [super loadView];
+
+ UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; // autoreleased
+
+ [button setTitle:@"Press Me!" forState:UIControlStateNormal];
+
+ [button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
+
+ CGRect buttonFrame = (CGRect){
+ roundf((self.view.frame.size.width - kButtonWidth)/2.0),
+ roundf((self.view.frame.size.height - kButtonHeight)/2.0),
+ kButtonWidth,
+ kButtonHeight
+ };
+ [button setFrame:buttonFrame];
+
+ [self.view addSubview:button];
+
+}
+
+- (void)buttonPressed {
+ [self showAlertViewWithMessage:@"Hello World!"];
+}
+
+- (void)showAlertViewWithMessage:(NSString *)message {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Button Pressed" message:@"Hello World!" delegate:self cancelButtonTitle:kCancelButtonTitle otherButtonTitles:kRepeatButtonTitle, nil];
+
+ [alert show];
+ [alert release];
+}
+
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
+ NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex];
+
+ if ([buttonTitle isEqualToString:kCancelButtonTitle]) {
+ // do nothing, it will cancel automatically
+ } else if ([buttonTitle isEqualToString:kRepeatButtonTitle]) {
+ [self showAlertViewWithMessage:@"Hello Again World!"];
+ }
+}
+
+@end
View
2 Project1/Project1/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
18 Project1/Project1/main.m
@@ -0,0 +1,18 @@
+//
+// main.m
+// Project1-noNib
+//
+// Created by Ian Davis on 11/25/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "AppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}

0 comments on commit 5128825

Please sign in to comment.