From Hello World to Finished App. raywenderlich.com
|
|
- Peter Bruce
- 6 years ago
- Views:
Transcription
1 From Hello World to Finished App
2 Why Learn ios? - Strong demand - Motivating - App Store - It s fun!
3 What s This All About? - One Day Crash Course - For beginners & intermediates - Making apps with UIKit - ios4 - Lots of demos - Hands-on focus
4 After Today You ll Have... - Written 3 ios apps! - From scratch! - That are actually useful! - Using common APIs! - Both iphone and ipad XP!
5 Non-Goals - Game Programming - Learning everything there is to know :]
6 Oh, and Epic Loot! - Epic loot to give away! - Thanks to Addison-Wesley! - To enter, send any Tweet with the following words before the Hello, ipad talk: - source: user from sxc.hu - Or... reach Uber Haxx0r level!
7 Hands-On Labs - Each section has a hands-on lab - Split into two parts: - Tutorial Walkthrough - Uber Haxx0r Challenge - 1st Uber Haxx0r at each challenge wins epic loot! - Max 1 prize :]
8 Today s Schedule
9 Today s Schedule - Morning: - Objective-C Crash Course - Hello, iphone! - Common UIKit Controls
10 Today s Schedule - Morning: - Objective-C Crash Course - Hello, iphone! - Common UIKit Controls - Lunch!
11 Today s Schedule - Morning: - Objective-C Crash Course - Hello, iphone! - Common UIKit Controls - Afternoon: - Table Views and Navigation - Saving Data - Hello, ipad! - Lunch!
12 Today s Schedule - Morning: - Objective-C Crash Course - Hello, iphone! - Common UIKit Controls - Lunch! - Afternoon: - Table Views and Navigation - Saving Data - Hello, ipad! - Beer!
13 About Me - Ray Wenderlich - Indie dev for ~2 years - Writes ios tutorials -
14 Objective-C Crash Course
15 What We ll Cover - Getting Started - Creating a Class - Memory Management - Objective-C Properties - Useful Classes
16 Demo: Getting Started - Start up Xcode - From the menu, choose File\New\New Project - Choose ios\application\view-based Application, click Next - Enter HelloObjC for Product Name, click Next - Choose where to save and click Create
17 Demo: Getting Started - Click Run - Shows just an empty. - Open HelloObjCAppDelegate.m - Add some test code like so: - (BOOL)application:(UIApplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // Add test code inside here, it will run on startup! :D NSLog(@"Hello, console!"); } // Override point for customization after application launch. self.window.rootviewcontroller = self.viewcontroller; [self.window makekeyandvisible]; return YES;
18 Demo: Getting Started
19 Creating a Class source: xkcd
20 Creating a Class - Class Name: DateCalculator - Get and set your age - Have a method to return whether you should date someone given her age Hayden Panettiere from Heroes - too Young to Date? She s 22! source: Glenn Francis
21 Objective-C Cheat Sheet
22 Demo: Creating a Class - Control-click HelloObjC group - Select New File... - Select ios\cocoa Touch \Objective-C class, click Next - Enter Subclass of NSObject, click Next - Type DateCalculator.m, click Save
23 Demo: Creating a Class // DateCalculator.h #import DateCalculator : NSObject { float _myage; } - (void)setmyage:(float)myage; - (float)myage; -
24 Demo: Creating a Class // DateCalculator.m #import DateCalculator - (void)setmyage:(float)myage { _myage = myage; } - (float)myage { return _myage; } - (BOOL)shouldIDateIfHerDateIs:(float)herAge { float minagetodate = _myage/2 + 7; return herage > minagetodate;
25 Demo: Creating a Class #import "DateCalculator.h" DateCalculator * calc = [[DateCalculator alloc] init]; [calc setmyage:31]; BOOL shoulddate = [calc shouldidateifherdateis:22]; if (shoulddate) { NSLog(@"It's OK to date Hayden!"); } else { NSLog(@"You shouldn't date Hayden, you old man!"); } [calc release];
26 Memory Management
27 Memory Management - All Objective-C classes should subclass NSObject - NSObject classes are reference counted - When reference count == 0, memory released
28 Memory Management - All Objective-C classes should subclass NSObject - NSObject classes are reference counted - When reference count == 0, memory released - ARC automatically manages ref count
29 Memory Management - All Objective-C classes should subclass NSObject - NSObject classes are reference counted - When reference count == 0, memory released - ARC automatically manages ref count - Managing ref count: - init: reference count = 1 - release: reference count -- - retain: reference count ++ - autorelease: reference count -- (later on)
30 Memory Management - Methods beginning with init or copy return objects with ref count of 1 - You need to release these when you re done NSArray *myarray = [[NSArray alloc] initwithobjects:obj1, obj2, nil]; // Use myarray, and when done... [myarray release]; - Anything else returns autorelease objects - You need to retain these if you don t want them to go away NSArray *myarray = [NSArray arraywithobjects:obj1, obj2, nil]; // You can use this as much as you want until the next run loop. // If you need if after that, you need to retain it... [myarray retain]; // And when you're done... [myarray release];
31 Objective-C Properties - Writing getters and setters is very common - Writing them correctly can be difficult - Objective-C properties make writing getters/ setters easier and safer
32 Useful Classes - NSString - Collections: - NSArray - NSDictionary - Mutable vs. Immutable - NSValue
33 Objective-C Cheat Sheet
34 Demo: Adding Properties // In (assign) float myage; // Delete previously written getter/setter // In myage = _myage; // Delete previously written getter/setter
35 Demo: Adding Custom Init // In DateCalculator.h // NSString * _myname; (retain) NSString * myname; - (id)initwithmyname:(nsstring *)myname andmyage:(int)myage; // In myname = _myname; - (id)initwithmyname:(nsstring *)myname andmyage:(int)myage { if ((self = [super init])) { self.myname = myname; self.myage = myage; } return self; } - (void)dealloc { [_myname release]; [super dealloc]; }
36 Demo: NSString, NSArray // Replace test code in HelloObjCAppDelegate.m with this NSArray * girls = nil]; NSArray * ages = [NSArray arraywithobjects: [NSNumber numberwithfloat:22], [NSNumber numberwithfloat:27], [NSNumber numberwithfloat:36], nil]; DateCalculator * calc = [[DateCalculator alloc] initwithmyname:@"ray" andmyage:31]; for (int i = 0; i < girls.count; ++i) { NSString *girl = [girls objectatindex:i]; NSNumber *age = [ages objectatindex:i]; BOOL shoulddate = [calc shouldidateifherdateis:age.floatvalue]; NSString *message; if (shoulddate) { message = [NSString stringwithformat:@"%@, it is OK to date %@.", calc.myname, girl]; } else { message = [NSString stringwithformat:@"%@, you are too old to date %@!", calc.myname, girl]; } NSLog(@"%@", message); } [calc release];
37 Lab Time! source: hdwarriors.com
38 Hello, iphone!
39 What We ll Cover - Xcode layout - App Structure - Interface Builder - Connecting controls to properties - Connecting actions to methods - Xcode s debugger
40 Demo: Xcode Layout Run, test, profile, or analyze app (hold down for options) Status display Just Standard editor Turn on Assistant editor Stop running app Run in iphone sim, ipad sim, or device? Groups & Files Standard editor Assistant editor Change visible file
41 Demo: Xcode Layout Turn on Navigator Turn on Debug area Turn on Utilities Navigator Debug Area Utilities Inspectors Libraries
42 Demo: Xcode Layout
43 App Structure - We chose View-Based Application Template - It made us: - An application delegate - A main Window - A single view controller - A single (empty) view
44 App Structure Main Window (this example: in MainWindow.xib)
45 App Structure Main Window (this example: in MainWindow.xib) subview View (this example: in HelloObjCViewController.xib )
46 App Structure Main Window (this example: in MainWindow.xib) subview View (this example: in HelloObjCViewController.xib ) subview Label (this example: in HelloObjCViewController.xib )
47 App Structure Main Window (this example: in MainWindow.xib) subview View Controller (this example: in HelloObjCViewController.h/m ) View (this example: in HelloObjCViewController.xib ) subview Label (this example: in HelloObjCViewController.xib )
48 App Structure Main Window (this example: in MainWindow.xib) subview View (this example: in HelloObjCViewController.xib ) references View Controller (this example: in HelloObjCViewController.h/m ) subview Label (this example: in HelloObjCViewController.xib )
49 App Structure Main Window (this example: in MainWindow.xib) subview View (this example: in HelloObjCViewController.xib ) subview references View Controller (this example: in HelloObjCViewController.h/m ) Model (this example: in DateCalculator.h/m ) Label (this example: in HelloObjCViewController.xib )
50 App Structure Main Window (this example: in MainWindow.xib) subview View (this example: in HelloObjCViewController.xib ) subview references View Controller (this example: in HelloObjCViewController.h/m ) references Model (this example: in DateCalculator.h/m ) Label (this example: in HelloObjCViewController.xib )
51 View Lifecycle - Methods in UIViewController: - viewdidload - viewwillappear - viewdidappear - viewwilldisappear - viewdiddisappear - viewdidunload
52 View Lifecycle - Methods in UIViewController: - viewdidload - viewwillappear Called first time viewcontroller s view property accessed. Important: can be called more than once! - viewdidappear - viewwilldisappear - viewdiddisappear - viewdidunload
53 View Lifecycle - Methods in UIViewController: - viewdidload - viewwillappear - viewdidappear - viewwilldisappear Called first time viewcontroller s view property accessed. Important: can be called more than once! Often a good place to populate views from model. - viewdiddisappear - viewdidunload
54 View Lifecycle - Methods in UIViewController: - viewdidload - viewwillappear - viewdidappear - viewwilldisappear - viewdiddisappear - viewdidunload Called first time viewcontroller s view property accessed. Important: can be called more than once! Often a good place to populate views from model. Happens when view controller is no longer visible, and a memory warning occurs.
55 Demo: Interface Builder Ref to the object that loads the XIB These get created when XIB loaded Inspector for selection, has multiple tabs Interface Builder XIB (Xcode Interface Builder) Main view Subview Expands pane Assistant editor set to automatic, so shows current view controller Object library
56 Demo: Interface Builder 1) Assistant editor set to automatic, so shows current view controller 2) Control-drag from label to right 3) Enter name of outlet, and click Connect
57 Demo: What It Did // HelloObjCViewController.h // Added an instance variable UILabel *resultlabel; } Control-click to see IBOutlets for View Controller // Added a property after // marked it as IBOutlet and (nonatomic, retain) IBOutlet UILabel *resultlabel; // HelloObjCViewController.m // Synthesized resultlabel; // Released label in dealloc [resultlabel release]; Can drag from this circle to the UILabel to connect. // Set label to nil (effectively releasing) in viewdidunload [self setresultlabel:nil];
58 Demo: Interface Builder 1) Assistant editor set to automatic, so shows current view controller 2) Control-drag from button to right 3) Set Connection to Action 4) Type in name of method to create and click Connect
59 Demo: What It Did // HelloObjCViewController.h Control-click to see Actions for Button // Declared a new method, marked as IBAction - (IBAction)calculateTapped:(id)sender; // HelloObjCViewController.m // Added stub for new method - (IBAction)calculateTapped:(id)sender { } Can drag from this circle to the File s Owner. Will show any methods marked as IBAction in View Controller and you can connect.
60 Demo: Implementation // HelloObjCViewController.h // Add at top of file #import "DateCalculator.h" // Add DateCalculator * _datecalculator; // (retain) DateCalculator * datecalculator; // HelloObjCViewController.m #import HelloObjCViewController // HelloObjCViewController.m // datecalculator = _datecalculator; // Release datecalculator in dealloc AND viewdidunload [_datecalculator release]; // Uncomment and implement viewdidload - (void)viewdidload { self.datecalculator = [[[DateCalculator alloc] initwithmyname:@"ray" andmyage:31] autorelease]; [super viewdidload]; } // Add to viewdidunload self.datecalculator = nil; // Implement calculatetapped - (IBAction)calculateTapped:(id)sender { BOOL shoulddate = [_datecalculator shouldidateifherdateis:22]; NSString *message; if (shoulddate) { message = [NSString stringwithformat:@"%@, it is OK to date her.", _datecalculator.myname]; } else { message = [NSString stringwithformat:@"%@, you are too old to date her!", _datecalculator.myname]; } resultlabel.text = message; }
61 Demo: Xcode s Debugger Click in margin to set breakpoints Toggles Debugger Call Stack Continue Step Over Step Into & Out Expand self to see instance variables Shows console + variables
62 Lab Time!
63 Common UIKit Controls
64 What We ll Cover - Useful UIKit Controls - Protocols and Delegates - MadLibs Demo - Device Orientation
65 UILabel - Set text with text property - Particularly useful settings: - Changing alignment - Lines - Changing font - Adjust to fit - Shadow
66 UITextView - Set with text property - Good for multi-line text - Also editable and scrollable! - Particularly useful settings: - Auto-detect phone # s, addresses, etc. - Scroll settings
67 UIButton - To get callback on click: connect to Touch Up Inside action - To set custom image for button: Type->Custom, change Image - Buttons have different states - Default, Highlighted, Selected, Disabled - Can have different titles/images/etc. for each state
68 UISlider - To get callback on slider value changing: connect to Value Changed action - To get current value of slider: value property - Particularly useful settings: - min/max/initial values - min/max images
69 UISegmentedControl - To get selected index: selectedsegmentindex property - Can set up segments directly in Interface Builder
70 UIImageView - Simply set the image - Programatic change via image property - Change the mode to affect the scaling/positioning behavior: - Scale to Fill - Aspect Fit/Aspect Fill - Center/Top/Left/etc.
71 UITextField - To get text, use text property - Particularly useful settings: - Clear Button - Capitalize/Correction - Keyboard/Return Key - By default, keyboard will not disappear when the return key is tapped!
72 Protocols and Delegates
73 Protocols and Delegates - You already know how to connect actions on a Control to methods - Like Touch Up Inside on a Button - But sometimes actions aren t enough!
74 Protocols and Delegates - You already know how to connect actions on a Control to methods - Like Touch Up Inside on a Button - But sometimes actions aren t enough! - For more info: - View controller implements an interface (called a protocol) - Set View Controller as delegate of control
75 Protocols and Delegates - You already know how to connect actions on a Control to methods - Like Touch Up Inside on a Button - But sometimes actions aren t enough! - For more info: - View controller implements an interface (called a protocol) - Set View Controller as delegate of control
76 Protocols and Delegates - You already know how to connect actions on a Control to methods - Like Touch Up Inside on a Button - But sometimes actions aren t enough! - For more info: - View controller implements an interface (called a protocol) - Set View Controller as delegate of control Control-click to see outlets for text field. One outlet is its delegate!
77 Protocols and Delegates - You already know how to connect actions on a Control to methods - Like Touch Up Inside on a Button - But sometimes actions aren t enough! - For more info: - View controller implements an interface (called a protocol) - Set View Controller as delegate of control Control-click to see outlets for text field. One outlet is its delegate! Drag from this circle to File s Owner to set the View Controller as the Text Field s delegate.
78 Protocols and - (BOOL)textFieldShouldBeginEditing:(UITextField *)textfield; - (void)textfielddidbeginediting:(uitextfield *)textfield; - (BOOL)textFieldShouldEndEditing:(UITextField *)textfield; - (void)textfielddidendediting:(uitextfield *)textfield; - (BOOL)textField:(UITextField *)textfield shouldchangecharactersinrange: (NSRange)range replacementstring:(nsstring *)string; - (BOOL)textFieldShouldClear:(UITextField *)textfield; - UITextField : UIControl <UITextInputTraits, NSCoding> { id<uitextfielddelegate> _delegate; // Stuff... }
79 Protocols and - (BOOL)textFieldShouldBeginEditing:(UITextField *)textfield; - (void)textfielddidbeginediting:(uitextfield *)textfield; - (BOOL)textFieldShouldEndEditing:(UITextField *)textfield; - (void)textfielddidendediting:(uitextfield *)textfield; - (BOOL)textField:(UITextField *)textfield shouldchangecharactersinrange: (NSRange)range replacementstring:(nsstring *)string; - (BOOL)textFieldShouldClear:(UITextField *)textfield; - (BOOL)textFieldShouldReturn:(UITextField Declare a protocol. Specify required and optional UITextField : UIControl <UITextInputTraits, NSCoding> { id<uitextfielddelegate> _delegate; // Stuff... }
80 Protocols and - (BOOL)textFieldShouldBeginEditing:(UITextField *)textfield; - (void)textfielddidbeginediting:(uitextfield *)textfield; - (BOOL)textFieldShouldEndEditing:(UITextField *)textfield; - (void)textfielddidendediting:(uitextfield *)textfield; - (BOOL)textField:(UITextField *)textfield shouldchangecharactersinrange: (NSRange)range replacementstring:(nsstring *)string; - (BOOL)textFieldShouldClear:(UITextField *)textfield; - (BOOL)textFieldShouldReturn:(UITextField Declare a protocol. Specify required and optional UITextField : UIControl <UITextInputTraits, NSCoding> { id<uitextfielddelegate> _delegate; // Stuff... } This class stores a reference to a class that implements UITextFieldDelegate.
81 Protocols and MadLibsViewController : UIViewController <UITextFieldDelegate> { // Stuff... } - (BOOL)textFieldShouldReturn:(UITextField *)textfield { } int i = [_textfields indexofobject:textfield]; if (i < [_textfields count] - 1) { UITextField *nexttextfield = [_textfields objectatindex:i+1]; [nexttextfield becomefirstresponder]; } else { [textfield resignfirstresponder]; } return TRUE;
82 Protocols and MadLibsViewController : UIViewController <UITextFieldDelegate> { // Stuff... } Mark the class as implementing the UITextFieldDelegate. - (BOOL)textFieldShouldReturn:(UITextField *)textfield { } int i = [_textfields indexofobject:textfield]; if (i < [_textfields count] - 1) { UITextField *nexttextfield = [_textfields objectatindex:i+1]; [nexttextfield becomefirstresponder]; } else { [textfield resignfirstresponder]; } return TRUE;
83 Protocols and MadLibsViewController : UIViewController <UITextFieldDelegate> { // Stuff... } Mark the class as implementing the UITextFieldDelegate. - (BOOL)textFieldShouldReturn:(UITextField *)textfield { } int i = [_textfields indexofobject:textfield]; if (i < [_textfields count] - 1) { UITextField *nexttextfield = [_textfields objectatindex:i+1]; [nexttextfield becomefirstresponder]; } else { [textfield resignfirstresponder]; } return TRUE; Implement any methods you care about. Since you set the view controller as the text field s delegate in Interface Builder, this will be called!
84 Protocols and MadLibsViewController : UIViewController <UITextFieldDelegate> { // Stuff... } Mark the class as implementing the UITextFieldDelegate. Move focus to nexttextfield Hide keyboard - (BOOL)textFieldShouldReturn:(UITextField *)textfield { } int i = [_textfields indexofobject:textfield]; if (i < [_textfields count] - 1) { UITextField *nexttextfield = [_textfields objectatindex:i+1]; [nexttextfield becomefirstresponder]; } else { [textfield resignfirstresponder]; } return TRUE; Implement any methods you care about. Since you set the view controller as the text field s delegate in Interface Builder, this will be called!
85 Demo: Mad Libs - Layout interface - Connect controls to outlets - Text fields - Segmented Control - Slider - Slider Label - Text Area
86 Demo: Mad Libs - Connect TouchUpInside on Button to method - Connect ValueChanged on Slider to method - Set Slider attributes - (IBAction)sliderValueChanged:(id)sender { numberlabel.text = [NSString stringwithformat:@"%d", (int) slider.value]; }
87 Demo: Mad Libs - Set the delegate of all 4 text fields to File s Owner (the View Controller)
88 Demo: Mad Libs // MadLibsViewController.h // to mark as implementing MadLibsViewController : UIViewController <UITextFieldDelegate> { // Add NSArray * _textfields; // (retain) NSArray * textfields; // MadLibsViewController.m // textfields = _textfields; // Add in dealloc [_textfields release]; // Uncomment viewdidload and add the following self.textfields = [NSArray arraywithobjects:pasttenseverb, singularnoun, pluralnoun, phrase, nil]; // Add in viewdidunload [self settextfields:nil]; // Add new method - (BOOL)textFieldShouldReturn:(UITextField *)textfield { } int i = [_textfields indexofobject:textfield]; if (i < [_textfields count] - 1) { UITextField *nexttextfield = [_textfields objectatindex:i+1]; [nexttextfield becomefirstresponder]; } else { [textfield resignfirstresponder]; } return TRUE;
89 Demo: Mad Libs - (IBAction)goTapped:(id)sender { NSString *placestring; if (place.selectedsegmentindex == 0) { placestring } else { placestring } } result.text = [NSString day, at %@ a %@ %@ %@ %@ and said, %@!", placestring, singularnoun.text, pasttenseverb.text, numberlabel.text, pluralnoun.text, phrase.text];
90 Device Orientation - iphone supports four orientations: - Portrait, Portrait Upside Down - Landscape Left, Landscape Right - Your app can (and should) reorient your views to support orientation changes - With Interface Builder, it s easy!
91 Demo: Device Orientation - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return YES; }
92 Lab Time!
93 Table Views and Navigation
94 What We ll Cover - View-Based App Template Walkthrough - Navigation Controllers - Table Views - UIImagePickerController - 5-Minute Break - Demo App
95 Demo: View-Based App Template Walkthrough // main.m (under Supporting Files) Last parameter is nil... #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int retval = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retval; } So look in the Info.plist and load this XIB/NIB!
96 Demo: View-Based App Template Walkthrough File s Owner is UIApplication An instance of the App Delegate, View Controller, and Window are created when this XIB is loaded App Delegate has outlets connected to the view controller and window that were created App Delegate is the delegate of File s Owner (UIApplication)
97 Demo: View-Based App Template Walkthrough // MadLibsAppDelegate.m - (BOOL)application:(UIApplication *)application didfinishlaunchingwithoptions: (NSDictionary *)launchoptions { self.window.rootviewcontroller = self.viewcontroller; [self.window makekeyandvisible]; return YES; } Sets which View Controller shows up on startup. Can set this in Interface Builder too!
98 Navigation Controllers - Provides easy way to drill down to different view controllers - Set up with root view controller - Stack based model - pushviewcontroller - popviewcontroller
99 Navigation Controllers - UIViewControllers have special properties to access parts of their Navigation Controller: - self.navigationcontroller - self.navigationitem.leftbarbuttonitem - self.navigationitem.title - self.navigationitem.rightbarbuttonitem - And more!
100 Introducing Scary Bugs
101 Demo: Navigation Controllers
102 Demo: Navigation Controllers
103 Demo: Navigation Controllers
104 Demo: Navigation Controllers A Navigation Controller is the Window s rootviewcontroller
105 Demo: Navigation Controllers A Navigation Controller is the Window s rootviewcontroller The top thing in the Navigation Controller Stack is a view controller called RootViewController (confusing name I know)
106 Demo: Navigation Controllers A Navigation Controller is the Window s rootviewcontroller The top thing in the Navigation Controller Stack is a view controller called RootViewController (confusing name I know) Sets Class in Identity Inspector, and NIB name in Attributes Inspector
107 Demo: Navigation Controllers A Navigation Controller is the Window s rootviewcontroller The top thing in the Navigation Controller Stack is a view controller called RootViewController (confusing name I know) Sets Class in Identity Inspector, and NIB name in Attributes Inspector Want a different View Controller first? Just change these!
108 Demo: Navigation Controllers The template s made the RootViewController.xib a UITableViewController (more on this later)
109 Demo: Navigation Controllers
110 Demo: Navigation Controllers
111 Demo: Navigation Controllers // DetailViewController.m // Add inside viewdidload self.navigationitem.title self.navigationitem.rightbarbuttonitem = [[[UIBarButtonItem alloc] initwithtitle:@"clickme" style:uibarbuttonitemstylebordered target:self action:@selector(clickmetapped:)] autorelease]; // Add new method - (void)clickmetapped:(id)sender { // Just for demonstration purposes NSLog(@"You clicked me!"); [self.navigationcontroller popviewcontrolleranimated:yes]; }
112 Demo: Navigation Controllers // RootViewController.h #import <UIKit/UIKit.h> #import RootViewController : UITableViewController { DetailViewController * _detailviewcontroller; (retain) DetailViewController * // RootViewController.m // detailviewcontroller = _detailviewcontroller; // Add inside viewdidload self.navigationitem.title // For testing purposes, replace return statement in tableview:numberofrowsinsection with this return 10; // For testing purposes, add the following in tableview:cellforrowatindexpath before the return statement cell.textlabel.text = [NSString stringwithformat:@"row %d", indexpath.row]; // Add inside tableview:didselectrowatindexpath if (_detailviewcontroller == nil) { self.detailviewcontroller = [[[DetailViewController alloc] initwithnibname:nil bundle:nil] autorelease]; } [self.navigationcontroller pushviewcontroller:_detailviewcontroller animated:yes]; // Add in dealloc [_detailviewcontroller release];
113 Table Views - Scrollable list of items - Each row: table view cell - Optimized to reuse cells for speed - To use, implement UITableViewDelegate and UITableViewDataSource
114 Table Views plain grouped
115 Table Views - tableview:numberofsectionsintableview - tableview:titleforheaderinsection - tableview:numberofrowsinsection - tableview:cellforrowatindexpath - tableview:didselectrowatindexpath
116 Table Views - Built-in cell styles: - UITableViewCellStyleDefault - UITableViewCellStyleSubtitle - UITableViewCellStyleValue1 - UITableViewCellStyleValue2 - Built-in cell properties: - textlabel, detailtextlabel, imageview
117 Demo: Table Views - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableview { return 1; } - (NSInteger)tableView:(UITableView *)tableview numberofrowsinsection: (NSInteger)section { return 10; } - (void)tableview:(uitableview *)tableview didselectrowatindexpath: (NSIndexPath *)indexpath { if (_detailviewcontroller == nil) { self.detailviewcontroller = [[[DetailViewController alloc] initwithnibname:nil bundle:nil] autorelease]; } [self.navigationcontroller pushviewcontroller:_detailviewcontroller animated:yes]; }
118 Demo: Table Views - (UITableViewCell *)tableview:(uitableview *)tableview cellforrowatindexpath: (NSIndexPath *)indexpath { static NSString *CellIdentifier As cells scroll offscreen, they are reused! Take care! UITableViewCell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initwithstyle:uitableviewcellstylevalue2 reuseidentifier:cellidentifier] autorelease]; } } // Configure the cell. cell.textlabel.text Norris"; cell.imageview.image = [UIImage imagenamed:@"icon.png"]; cell.detailtextlabel.text return cell;
119 UIImagePickerController - Easy way to let users choose/take photos (set sourcetype) - Create with alloc/init, set sourcetype - Display with presentmodalviewcontroller - Set self as delegate, receive didfinishpickingmediawithinfo callback
120 Demo: Scary Bugs #import ScaryBug : NSObject { NSString * _name; UIImage * _image; float _howscary; (retain) NSString * (retain) UIImage * (assign) float howscary; - (id)initwithname:(nsstring *)name image:(uiimage *)image howscary: #import name = image = howscary = _howscary; - (id)initwithname:(nsstring *)name image: (UIImage *)image howscary:(float)howscary { if ((self = [super init])) { self.name = name; self.image = image; self.howscary = howscary; } return self; } - (void)dealloc { [_name release]; [_image release]; [super dealloc];
121 Demo: Scary Bugs // ScaryBugsAppDelegate.m // At top of file #import "RootViewController.h" #import "ScaryBug.h" // At top of application:didfinishlaunchingwithoptions ScaryBug * centipede = [[[ScaryBug alloc] initwithname:@"centipede" image: [UIImage imagenamed:@"centipede.jpg"] howscary:3.0] autorelease]; ScaryBug * ladybug = [[[ScaryBug alloc] initwithname:@"ladybug" image: [UIImage imagenamed:@"ladybug.jpg"] howscary:1.0] autorelease]; ScaryBug * potatobug = [[[ScaryBug alloc] initwithname:@"potato Bug" image: [UIImage imagenamed:@"potatobug.jpg"] howscary:4.0] autorelease]; ScaryBug * wolfspider = [[[ScaryBug alloc] initwithname:@"wolf Spider" image: [UIImage imagenamed:@"wolfspider.jpg"] howscary:5.0] autorelease]; NSMutableArray * bugs = [NSMutableArray arraywithobjects: centipede, ladybug, potatobug, wolfspider, nil]; RootViewController * rootviewcontroller = [self.navigationcontroller.viewcontrollers objectatindex:0]; rootviewcontroller.bugs = bugs;
122 Demo: Scary Bugs // RootViewController.h // Add at top of file #import "ScaryBug.h" // Add NSMutableArray * _bugs; } // (retain) NSMutableArray * bugs; // RootViewController.m // bugs = _bugs; // Inside numberofrowsinsection return _bugs.count; // Add inside viewwillappear [self.tableview reloaddata]; // Inside cellforrowatindexpath ScaryBug * bug = [_bugs objectatindex:indexpath.row]; cell.textlabel.text = bug.name; cell.imageview.image = bug.image; // Inside didselectrowatindexpath ScaryBug * bug = [_bugs objectatindex:indexpath.row]; _detailviewcontroller.bug = bug; // Add in dealloc [_bugs release];
123 Demo: Scary Bugs #import <UIKit/UIKit.h> #import DetailViewController : UIViewController { ScaryBug * _bug; (retain) ScaryBug *
124 Demo: Scary Bugs // DetailViewController.m // bug = _bug; // Add inside dealloc [_bug release]; // Add new method - (void)viewwillappear:(bool)animated { _textfield.text = _bug.name; _imageview.image = _bug.image; _slider.value = _bug.howscary; } // DetailViewController.h // Mark as implementing these DetailViewController : UIViewController <UIImagePickerControllerDelegate, UITextFieldDelegate> // Add inside textfieldeditingchanged _bug.name = _textfield.text; // Add inside slidervaluechanged _bug.howscary = _slider.value; // Add inside buttontapped UIImagePickerController * picker = [[[UIImagePickerController alloc] init] autorelease]; picker.sourcetype = UIImagePickerControllerSourceTypePhotoLibrary; picker.allowsediting = NO; picker.delegate = self; [self presentmodalviewcontroller:picker animated:yes]; // Add new methods -(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo: (NSDictionary *)info { UIImage *image = [info objectforkey:uiimagepickercontrolleroriginalimage]; _bug.image = image; [self dismissmodalviewcontrolleranimated:yes]; } -(BOOL)textFieldShouldReturn:(UITextField *)textfield { [_textfield resignfirstresponder]; return YES; }
125 Lab Time!
126 Saving Data
127 What We ll Cover - Working with paths and files - Survey of ways to save your app s data - Demo: using some of the simplest ways in Scary Bugs
128 Many Ways to Save Data - NSData/NSString - fread/fwrite - SQLite - Core Data - User Defaults - Property List Serialization - NSCoding
129 Many Ways to Save Data - NSData/NSString - fread/fwrite - User Defaults - Property List Serialization - NSCoding - SQLite - Core Data Which to choose?!
130 Getting Paths to Files - For files included in your Xcode project: NSString * path = [[NSBundle mainbundle] pathforresource:@"centipede" oftype:@"jpg"]; - But be careful: read-only!
131 Getting Paths to Files - NSSearchPathForDir ectoriesindomains - NSDocumentDirectory (file sharing enabled) NSArray * docdirs = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *docdir = [docdirs objectatindex:0]; - NSLibraryDirectory (appspecific contents don t want shared) - NSCachesDirectory (not backed up)
132 Getting Paths to Files - NSString has many helpful methods related to paths - stringbyappendingpathcomponent - lastpathcomponent - pathextension - stringbydeletinglastpathcomponent NSString *fullpath = [docdir stringbyappendingpathcomponent:@"mydoc.txt"];
133 Reading Files - NSData gets raw bytes: NSData * data = [NSData datawithcontentsoffile:path]; if (data) { void * buffer = [data bytes]; NSUInteger bufferlen = [data length]; } - Or can get as NSString: NSError * error; NSString * string = [NSString stringwithcontentsoffile:path encoding:nsutf8stringencoding error:&error]; if (string) { NSLog(@"%@", string); }
134 Writing Files - Can also write NSData: BOOL success = [data writetofile:path atomically:yes]; - Or NSString: NSError *error; BOOL success = [string writetofile:path atomically:yes encoding:nsutf8stringencoding error:&error];
135 Reading/Writing Files - NSData/NSString methods are convenient, but read/write entire files at once - Can be a problem for large files (memory, speed). - Want to read/write part at a time? - fread/fwrite - Higher-level APIs such as SQLite, Core Data
136 Managing Dirs and Files - NSFileManager - Access from anywhere - [[NSFileManager defaultmanager] - fileexistsatpath - contentsofdirectoryatpath:error - createdirectoryatpath:withintermed iatedirectories:attributes:error - removeitematpath:error
137 User Defaults - Easy way to store/read small amounts of data NSUserDefaults *userdefaults = [NSUserDefaults standarduserdefaults]; if ([userdefaults boolforkey:@"hasrunbefore"] == FALSE) { [userdefaults setbool:yes forkey:@"hasrunbefore"]; [userdefaults synchronize]; } NSLog(@"First time run!"); - Can store primitives: floats, doubles, integers, booleans - Also objects: NSString, NSNumber, NSDate, NSArray, NSDictionary, NSData, NSURL
138 Property List Serialization - Extremely easy to read/write/create, but limited NSString *path = [[NSBundle mainbundle] pathforresource:@"filename" oftype:@"plist"]; NSDictionary * plistdict = [NSDictionary dictionarywithcontentsoffile:path];
139 NSCoding - Easy way to serialize objects to NSData - Great for apps without heavy data requirements - (void) encodewithcoder:(nscoder *)acoder { [acoder encodeobject:_title forkey:@"title"]; [acoder encodefloat:_rating forkey:@"rating"]; } - (id) initwithcoder:(nscoder *)adecoder { NSString *title = [adecoder decodeobjectforkey:@"title"]; float rating = [adecoder decodefloatforkey:@"rating"]; return [self initwithtitle:title andrating:rating]; }
140 NSCoding - To save: - Serialize root object using NSKeyedUnarchiver NSData * data = [NSKeyedArchiver archiveddatawithrootobject:rootviewcontroller.bugs]; - Then write that data to a file - To load: - Read data from file - Then Unserialize root object using NSKeyedUnarchiver NSArray * bugsarray = [NSKeyedUnarchiver unarchiveobjectwithdata:data];
141 SQLite - SQLite is a library that reads a SQL database as a flat file - You can perform SQL queries on it - Command line tool to work with SQLite dbs: sqlite3 - Advantages: can easily retrieve subset of data, leverage power of DB engine, small learning curve if familiar with SQL dbs - Overall: Can be quick to learn, but Core Data usually better for-iphone-developers-creating-and-scripting
142 Core Data - Object graph management and persistence framework - Use a visual editor to design your object structure - Store your objects in a SQLite db - Cache objects as you read them out - Automatically pull related objects - Overall: usually best way, but learning curve and time to implement core-data-tutorial-getting-started
143 Demo: Simple Saving // ScaryBugsAppDelegate.m, in applicationdidfinishlaunching BOOL hasrunbefore = [[NSUserDefaults standarduserdefaults] boolforkey:@"hasrunbefore"]; if (!hasrunbefore) { [[NSUserDefaults standarduserdefaults] setbool:yes forkey:@"hasrunbefore"]; [[NSUserDefaults standarduserdefaults] synchronize]; } UIAlertView * alertview = [[[UIAlertView alloc] initwithtitle:@"welcome!" message:@"welcome to Scary Bugs!" delegate:nil cancelbuttontitle:nil otherbuttontitles:@"w00t", nil] autorelease]; [alertview show];
144 Demo: Simple Saving
145 Demo: Simple Saving
146 Demo: Simple Saving // ScaryBugsAppDelegate.m, in applicationdidfinishlaunching NSMutableArray * bugs = [NSMutableArray array]; NSString *path = [[NSBundle mainbundle] pathforresource:@"defaultbugs" oftype:@"plist"]; NSDictionary * plistdict = [NSDictionary dictionarywithcontentsoffile:path]; NSArray * plistbugs = [plistdict objectforkey:@"data"]; for (NSDictionary * bugdict in plistbugs) { NSString *name = [bugdict objectforkey:@"name"]; NSString *image = [bugdict objectforkey:@"image"]; NSNumber * howscarynumber = [bugdict objectforkey:@"howscary"]; ScaryBug * bug = [[[ScaryBug alloc] initwithname:name image:[uiimage imagenamed:image] howscary:howscarynumber.floatvalue] autorelease]; [bugs addobject:bug]; }
147 Demo: Simple Saving // ScaryBug : NSObject <NSCoding> { // ScaryBug.m - (void)encodewithcoder:(nscoder *)acoder { [acoder encodeobject:_name forkey:@"name"]; NSData *data = UIImagePNGRepresentation(_image); [acoder encodeobject:data forkey:@"image"]; [acoder encodefloat:_howscary forkey:@"howscary"]; } - (id)initwithcoder:(nscoder *)adecoder { NSString *name = [adecoder decodeobjectforkey:@"name"]; NSData *imagedata = [adecoder decodeobjectforkey:@"image"]; UIImage * image = [UIImage imagewithdata:imagedata]; float howscary = [adecoder decodefloatforkey:@"howscary"]; return [self initwithname:name image:image howscary:howscary]; }
148 Demo: Simple Saving // ScaryBugsAppDelegate.m, in applicationdidfinishlaunching NSMutableArray * bugs = [NSMutableArray array]; NSArray * docdirs = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *docdir = [docdirs objectatindex:0]; NSString *bugspath = [docdir stringbyappendingpathcomponent:@"bugs.plist"]; if ([[NSFileManager defaultmanager] fileexistsatpath:bugspath]) { // File exists, let's load it NSData *data = [NSData datawithcontentsoffile:bugspath]; NSArray * bugsarray = [NSKeyedUnarchiver unarchiveobjectwithdata:data]; [bugs addobjectsfromarray:bugsarray]; } else { // Old code to load default bugs... }
149 Demo: Simple Saving // ScaryBugsAppDelegate.m - (void)applicationdidenterbackground:(uiapplication *)application { RootViewController * rootviewcontroller = [self.navigationcontroller.viewcontrollers objectatindex:0]; } NSArray * docdirs = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *docdir = [docdirs objectatindex:0]; NSString *bugspath = [docdir stringbyappendingpathcomponent:@"bugs.plist"]; NSData * data = [NSKeyedArchiver archiveddatawithrootobject:rootviewcontroller.bugs]; [data writetofile:bugspath atomically:yes];
150 Disadvantages and Alternatives Bugs saved in one massive file Load all bugs up-front Saves images along with the data Only saves on exit Alternative: one file per bug Alternative: load on demand Alternative: save images as separate files Alternative: save periodically, or on changes
151 Synchronizing and Sharing Data - Can use File Sharing to allow users to easily transfer files with itunes - If you get that working, easy to add sharing too - ios5: icloud - Or sync with your own web service
152 Lab Time!
153 Hello, ipad!
154 What We ll Cover - Compiling for ipad - Using UISplitViewController - Using UIPopoverController - Writing conditional code
155 Base SDK vs. Deployment Target - Base SDK: SDK you re compiling with (latest) - Deployment target: minimum OS version code compatible with
156 ios Users Tend to Upgrade /08/ios-versions-in-thewild/ source: apprupt.com
157 Building for ipad in Xcode - Targeted Device Family (in Project Settings) - Main nib file base name (in Info.plist)
158 The Biggest Difference Between Developing for ipad vs iphone
159 The Biggest Difference Between Developing for ipad vs iphone
160 The Biggest Difference Between Developing for ipad vs iphone
161 A bigger size leads to different UI paradigms...
162 Apple provides new UI elements to assist you... - Bigger view controllers - More composing - UISplitViewController - UIPopoverController
163 Demo: Bigger View Controllers
164 Demo: Bigger View Controllers // Modify tableview:didselectrowatindexpath if (_detailviewcontroller == nil) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { self.detailviewcontroller = [[[DetailViewController alloc] initwithnibname:@"detailviewcontroller-ipad" bundle:nil] autorelease]; } else { self.detailviewcontroller = [[[DetailViewController alloc] initwithnibname:nil bundle:nil] autorelease]; } }
165 Demo: UISplitViewController - Refactor AppDelegate to have reference to RootViewController
166 Demo: UISplitViewController // (retain) IBOutlet DetailViewController * detailviewcontroller;
167 Demo: UISplitViewController - Create refresh method on DetailViewController // RootViewController.m // Inside tableview:didselectrowatindexpath ScaryBug * bug = [_bugs objectatindex:indexpath.row]; _detailviewcontroller.bug = bug; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [_detailviewcontroller refresh]; } else { [self.navigationcontroller pushviewcontroller:_detailviewcontroller animated:yes]; }
168 Demo: UISplitViewController - Create toolbar, link to Outlet - Set DetailViewController as UISplitViewController s delegate // DetailViewController.h // Mark as implementing this DetailViewController : UIViewController <UIImagePickerControllerDelegate, UITextFieldDelegate, UISplitViewControllerDelegate> { // DetailViewController.m - (void)splitviewcontroller:(uisplitviewcontroller *)svc willhideviewcontroller:(uiviewcontroller *)aviewcontroller withbarbuttonitem: (UIBarButtonItem *)barbuttonitem forpopovercontroller:(uipopovercontroller *)pc { NSMutableArray * items = [NSMutableArray array]; [items addobject:barbuttonitem]; barbuttonitem.title [items addobjectsfromarray:_toolbar.items]; [_toolbar setitems:items]; } - (void)splitviewcontroller:(uisplitviewcontroller *)svc willshowviewcontroller:(uiviewcontroller *)aviewcontroller invalidatingbarbuttonitem:(uibarbuttonitem *)barbuttonitem { } NSMutableArray * items = [NSMutableArray array]; [items addobjectsfromarray:_toolbar.items]; [items removeobject:barbuttonitem]; [_toolbar setitems:items];
169 Demo: UIPopoverController // DetailViewController.h // Add UIPopoverController * _popover; // (retain) UIPopoverController * popover; // DetailViewController.m // popover = _popover; // Add in dealloc [_popover release]; // Add inside buttontapped if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if (_popover == nil) { self.popover = [[[UIPopoverController alloc] initwithcontentviewcontroller:picker] autorelease]; } UIButton *button = (UIButton *)sender; [_popover presentpopoverfromrect: CGRectMake(button.center.x, button.center.y, 10, 10) inview:self.view permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; } else { [self presentmodalviewcontroller:picker animated:yes]; }
170 The Final Challenge!
171 Where To Go From Here? - Make apps, gain money and skillz! - More ios dev tutorials on $75 off with discount code 360idev! - Drop me a note anytime!
172 Epic Loot Time!
Lab #1: Chuck Norris Joke Generator Class
Lab #1: Chuck Norris Joke Generator Class Chuck Norris does not need Twitter... he is already following you. Chuck Norris doesnʼt flush the toilet, he scares the sh*t out of it. Chuck Norris is the reason
More informationData IAP 2010 iphonedev.csail.mit.edu edward benson / Thursday, January 14, 2010
Data IAP 2010 iphonedev.csail.mit.edu edward benson / eob@csail.mit.edu Today Property Lists User Defaults Settings Panels CoreData Property Lists Today Add persistence. plist 1. Using Property Lists in
More informationITP 342 Mobile App Dev. Table Views
ITP 342 Mobile App Dev Table Views Table Views The most common mechanism used to display lists of data to the user Highly configurable objects that can be made to look practically any way you want them
More informationProduced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar
Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More informationios Mobile Development
ios Mobile Development Today UITableView! Data source-driven vertical list of views.! ipad! Device-specific UI idioms.! Demo! Shutterbug UITableView Very important class for displaying data in a table!
More informationLab #1: Chuck Norris Joke Generator Class
Lab #1: Chuck Norris Joke Generator Class Chuck Norris does not need Twitter... he is already following you. Chuck Norris doesn t flush the toilet, he scares the sh*t out of it. Chuck Norris is the reason
More informationIPHONE DEVELOPMENT. Getting Started with the iphone SDK
IPHONE DEVELOPMENT Getting Started with the iphone SDK OBJECTIVE-C The Big Picture STRICT SUPERSET OF C The Objective C Language Any C stuff applies Standard libs are here (time, sqrt etc) The C Language
More informationInterfaceBuilder and user interfaces
ES3 Lab 2 InterfaceBuilder and user interfaces This lab InterfaceBuilder Creating components Linking them to your code Adding buttons, labels, sliders UITableView Creating a tableview Customizing cells
More informationios Core Data Example Application
ios Core Data Example Application The Core Data framework provides an abstract, object oriented interface to database storage within ios applications. This does not require extensive knowledge of database
More informationsrc3/bettertextfield/bettertextfield/appdelegate.h // AppDelegate.h // BetterTextField
src3/bettertextfield/bettertextfield/appdelegate.h 1 1 1 1 AppDelegate.h BetterTextField Created by Tommy MacWilliam on 3/7/ Copyright (c) 2012 MyCompanyName. All rights reserved. #import
More informationNavigation bar (Xcode version 4.5.2) 1. Create a new project. From the Xcode menu, select File > New > Project
Navigation bar (Xcode version 4.5.2) 1. Create a new project. From the Xcode menu, select File > New > Project Choose the Single View Application template Click Next. In the Choose options for your new
More informationApple Development Technology Workshops
Apple Development Technology Workshops Workshop 10 Table Views Building iphone Apps. Pt 2 Fall 2008 Hafez Rouzati Fall 2008 Zach Pousman Last Week UIViewControllers Organizing Content & Building iphone
More informationAVAudioPlayer. avtouch Application
AVAudioPlayer avtouch Application iphone Application Index 1. iphone Application 1) iphone Application 2) iphone Application Main Method 3) iphone Application nib(.xib) 2. avtouch Application 1) avtouch
More informationStanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011
Developing Applications for ios Today UI Element of the Week UIToolbar ipad Split View Popover Universal (iphone + ipad) Application Demo Friday Section AVFoundation framework - Capturing and manipulating
More informationNaviga&on and Tab Bar Controllers and Table View
Naviga&on and Tab Bar Controllers and Table View UINaviga)onController Stack of view controllers Naviga)on bar How It Fits Together Top view controller s view Top view controller s )tle Previous view controller
More informationiphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5
iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 Questions? Announcements Assignment #1 due this evening by 11:59pm Remember, if you wish to use a free late you must email me before
More informationiphone Application Tutorial
iphone Application Tutorial 2008-06-09 Apple Inc. 2008 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any
More informationReview. Objective-C Classes, Methods, Properties, Protocols, Delegation, Memory Management
Data Persistence Review Objective-C Classes, Methods, Properties, Protocols, Delegation, Memory Management Foundation NSArray, NSDictionary, NSString (and mutable versions thereof) MVC and UIViewController
More informationToday s Topics. Scroll views Table views. UITableViewController Table view cells. Displaying data Controlling appearance & behavior
Today s Topics Scroll views Table views Displaying data Controlling appearance & behavior UITableViewController Table view cells Scroll Views UIScrollView For displaying more content than can fit on the
More informationYour First iphone OS Application
Your First iphone OS Application General 2010-03-15 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form
More informationYour First iphone Application
Your First iphone Application General 2009-01-06 Apple Inc. 2009 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form
More informationComputer Science 251. iphone Application Development. Autorotation, Popover Controllers, Modal Controllers
Computer Science 251 iphone Application Development Autorotation, Popover Controllers, Modal Controllers Two Types of Orientation Device: physically upside down, rotated left, on its back, etc. Can be
More informationITP 342 Mobile App Dev. Table Views
ITP 342 Mobile App Dev Table Views Tables A table presents data as a scrolling, singlecolumn list of rows that can be divided into sections or groups. Use a table to display large or small amounts of information
More informationContents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need
iphone Training Contents About iphone Training Our ios training classes can help you get off to a running start in iphone, ipod and ipad app development. Learn from expert Objective-C developers with years
More informationDesigning iphone Applications
Designing iphone Applications 4 Two Flavors of Mail 5 Organizing Content 6 Organizing Content 6 Organizing Content 6 Organizing Content 6 Organizing Content Focus on your user s data 6 Organizing Content
More informationIntro to Native ios Development. Dave Koziol Arbormoon Software, Inc.
Intro to Native ios Development Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (20 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Wunder
More informationLife Cycle. Chapter Explore the Game Application. Understanding the Views in a Game
3 Chapter Explore the Game Application Life Cycle There is more to a game than just the fun parts. Almost all of the games on the market, and definitely the big titles, involve multiple views and a reasonably
More informationWidget Tour. iphone and ipod touch Development Fall 2009 Lecture 7
Widget Tour iphone and ipod touch Development Fall 2009 Lecture 7 Questions? Announcements Assignment #2 due Tonight by 11:59pm Today s Topics Controls Buttons Switches Sliders Segmented Controls Text
More informationITP 342 Mobile App Development. Data Persistence
ITP 342 Mobile App Development Data Persistence Persistent Storage Want our app to save its data to persistent storage Any form of nonvolatile storage that survives a restart of the device Want a user
More informationIOS - TEXT FIELD. Use of Text Field. Important Properties of Text Field. Updating Properties in xib
IOS - TEXT FIELD http://www.tutorialspoint.com/ios/ios_ui_elements_text_field.htm Copyright tutorialspoint.com Use of Text Field A text field is a UI element that enables the app to get user input. A UITextfield
More informationCS193P: HelloPoly Walkthrough
CS193P: HelloPoly Walkthrough Overview The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa Touch application. You are encouraged to follow the walkthrough,
More informationCS193P - Lecture 8. iphone Application Development. Scroll Views & Table Views
CS193P - Lecture 8 iphone Application Development Scroll Views & Table Views Announcements Presence 1 due tomorrow (4/28)! Questions? Presence 2 due next Tuesday (5/5) Announcements Enrolled students who
More informationiphone Programming Touch, Sound, and More! Norman McEntire Founder Servin Flashlight CodeTour TouchCount CodeTour
iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin 1 Legal Info iphone is a trademark of Apple Inc. Servin is a trademark of Servin Corporation 2 Welcome Welcome! Thank you! My promise
More informationCorrections and version notes
Last updated 7 th May, 2014 Programming apps for the iphone Corrections and version notes Please feel free to email Graeme (gbsummers@graemesummers.info) for additional help or clarification on any of
More informationimate: ios Application
imate: ios Application Document Version 1.0.1 Date: 27 th May, 2014 2 [IMATE: IOS APPLICATION] Contents AppDelegate Class Reference... 4 Tasks... 4 Properties... 4 Instance Methods... 4 ChatMenuViewController
More informationMy First iphone App (for Xcode version 6.4)
My First iphone App (for Xcode version 6.4) 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button
More informationITP 342 Mobile App Development. Data Persistence
ITP 342 Mobile App Development Data Persistence Persistent Storage Want our app to save its data to persistent storage Any form of nonvolatile storage that survives a restart of the device Want a user
More informationPraktikum Entwicklung von Mediensystemen mit
Praktikum Entwicklung von Mediensystemen mit Wintersemester 2013/2014 Christian Weiß, Dr. Alexander De Luca Today Table View Navigation Controller Passing Data Between Scenes Assignment 2 2 Navigation-based
More informationOVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net
OVERVIEW Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net Microsoft MVP for 4 years C#, WinForms, WPF, Silverlight Joined Cynergy about
More informationStanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015
Stanford CS193p Developing Applications for ios Today UITextField Bonus Topic! Table View A UIView for displaying long lists or tables of data UITextField Like UILabel, but editable Typing things in on
More informationTopics in Mobile Computing
Topics in Mobile Computing Workshop 1I - ios Fundamental Prepared by Y.H. KWOK What is ios? From Wikipedia (http://en.wikipedia.org/wiki/ios): ios is an operating system for iphone, ipad and Apple TV.
More informationiphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department
iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department pmadden@acm.org http://optimal.cs.binghamton.edu General Outline Overview of the tools, and where to get more information
More informationCS 6030 Bioinformatics Summer II 2012 Semester Project Final Report Chandana Sripha Guduru Jason Eric Johnson
CS 6030 Bioinformatics Summer II 2012 Semester Project Final Report Chandana Sripha Guduru Jason Eric Johnson 1 Team Members:! 3 Project Description:! 3 Project Goals:! 3 Research/Design:! 3 Web Service
More informationPage 1. GUI Programming. Lecture 13: iphone Basics. iphone. iphone
GUI Programming Lecture 13: iphone Basics Until now, we have only seen code for standard GUIs for standard WIMP interfaces. Today we ll look at some code for programming mobile devices. on the surface,
More informationlectures/2/src2/nib1/nib1/appdelegate.h // AppDelegate.h // Nib1 // David J. Malan // Harvard University //
lectures/2/src2/nib1/nib1/appdelegate.h 1 1 1 1 1 1 1 1 1 2 AppDelegate.h Nib1 David J. Malan Harvard University malan@harvard.edu Demonstrates a Single View Application implemented with a nib, plus IBAction
More informationMy First iphone App. 1. Tutorial Overview
My First iphone App 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button. You can type your name
More informationUser Experience: Windows & Views
View Controller Programming Guide for ios User Experience: Windows & Views 2011-01-07 Apple Inc. 2011 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval
More informationAVAudioRecorder & System Sound Services
AVAudioRecorder & System Sound Services Dept. of Multimedia Science, Sookmyung Women s University. prof. JongWoo Lee Index AVAudioRecorder? - (AudioRecorder) System Sound Service? - (SysSound) AVAudioRecorder
More informationObjective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008
Objective-C Primer iphone Programmer s Association Lorenzo Swank September 10, 2008 Disclaimer Content was blatantly and unapologetically stolen from the WWDC 2007 Fundamentals of Cocoa session, as well
More informationITP 342 Mobile App Dev. Connections
ITP 342 Mobile App Dev Connections User Interface Interactions First project displayed information to the user, but there was no interaction. We want the users of our app to touch UI components such as
More informationIntroductory ios Development
Introductory ios Development 152-164 Unit 5 - Multi-View Apps Quick Links & Text References What is a Delegate? What is a Protocol? Delegates, Protocols and TableViews Creating a Master-Detail App Modifying
More informationChapter 22 TableView TableView. TableView ios. ViewController. Cell TableViewCell TableView
Chapter 22 TableView TableView Android TableView ListView App 22.1 TableView TableView Storyboard Table View ViewController TableView ios Cell TableViewCell TableView Table View Cell Cell ImageView (imageview)
More information1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney
1 Build Your First App The way to get started is to quit talking and begin doing. Walt Disney Copyright 2015 AppCoda Limited All rights reserved. Please do not distribute or share without permission. No
More informationios 101 Hands-On Challenges
ios 101 Hands-On Challenges Copyright 2014 Razeware LLC. All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by
More informationDocument Version Date: 1st March, 2015
7 Minute Fitness: ios(swift) Application Document Version 1.0.1 Date: 1st March, 2015 2 [7 MINUTE FITNESS: APP DOCUMENTATION] Important Notes:... 5 AppDelegate Class Reference... 6 Tasks... 6 Instance
More informationITP 342 Mobile App Dev. Connections
ITP 342 Mobile App Dev Connections User Interface Interactions First project displayed information to the user, but there was no interaction. We want the users of our app to touch UI components such as
More informationIndex. btndrop function, 224, 226 btngetquote function, 246 btnpressed function, 28 btnquote method, 245. CallWeb method, 238, 240
Index A App icons section icons set, 277 LaunchImage, 278 launch screen graphics, 278 279 PNG format, 277 settings, 276 App store deployment application graphics, 273 general settings Identity section,
More informationPraktikum Entwicklung von Mediensystemen mit
Praktikum Entwicklung von Mediensystemen mit Sommersemester 2013 Fabius Steinberger, Dr. Alexander De Luca Today Organization Introduction to ios programming Hello World Assignment 1 2 Organization 6 ECTS
More informationCSC 581: Mobile App Development Spring 2018
CSC 581: Mobile App Development Spring 2018 Unit 2: Introduciton to the UIKit UIKit, UIViews UIControl subclasses 1 UIKit the UIKit is a code framework for building mobile apps the foundational class for
More informationAnnouncement. Final Project Proposal Presentations and Updates
Announcement Start Final Project Pitches on Wednesday Presentation slides dues by Tuesday at 11:59 PM Email slides to cse438ta@gmail.com Extensible Networking Platform 1 1 - CSE 438 Mobile Application
More informationStanford CS193p. Developing Applications for ios. Fall CS193p. Fall
Stanford Developing Applications for ios Today Drag and Drop Transferring information around within and between apps. EmojiArt Demo Drag and drop an image to get our EmojiArt masterpieces started. UITableView
More informationView Controllers CPRE 388
View Controllers CPRE 388 View Controllers Manage views in model view controller design template. Many types: custom view controller; container view controller; modal view controller. Custom View controllers
More informationNews- ipad: ios(swift) Application
News- ipad: ios(swift) Application Document Version 1.0.1 Date: 9 th Nov, 2014 2 [NEWS- IPAD: APP DOCUMENTATION] Important Notes:... 6 AppDelegate Class Reference... 7 Tasks... 7 Instance Methods... 7
More informationITP 342 Advanced Mobile App Dev. Memory
ITP 342 Advanced Mobile App Dev Memory Memory Management Objective-C provides two methods of application memory management. 1. In the method described in this guide, referred to as manual retain-release
More informationios Development - Xcode IDE
ios Development - Xcode IDE To develop ios applications, you need to have an Apple device like MacBook Pro, Mac Mini, or any Apple device with OS X operating system, and the following Xcode It can be downloaded
More informationAdvanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012
Advanced ios CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012 1 Goals of the Lecture Present a few additional topics and concepts related to ios programming persistence serialization
More informationTypes of Views. View category Purpose Examples of views. Display a particular type of content, such as an image or text.
ios UI Components Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Types of Views View
More informationStanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011
Developing Applications for ios Today Persistence How to make things stick around between launchings of your app (besides NSUserDefaults) Persistence Property Lists Use writetourl:atomically: and initwithcontentsofurl:
More informationLesson 1: Hello ios! 1
Contents Introduction xxv Lesson 1: Hello ios! 1 ios Developer Essentials 1 A Suitable Mac 1 A Device for Testing 2 Device Differences 2 An ios Developer Account 4 The Official ios SDK 6 The Typical App
More informationIntegrating Game Center into a BuzzTouch 1.5 app
into a BuzzTouch 1.5 app This tutorial assumes you have created your app and downloaded the source code; created an App ID in the ios Provisioning Portal, and registered your app in itunes Connect. Step
More informationWhy Model-View-Controller?
View Controllers Why Model-View-Controller? Ever used the word spaghetti to describe code? Clear responsibilities make things easier to maintain Avoid having one monster class that does everything Why
More informationITP 342 Advanced Mobile App Dev. Core Data
ITP 342 Advanced Mobile App Dev Core Data Persistent Data NSUser Defaults Typically used to save app preferences Property List (plist) in Documents Directory Data is in a dictionary or an array Coders
More informationCovers ios 6. Bear Cahill. Includes 98 Techniques MANNING
Bear Cahill Covers ios 6 Includes 98 Techniques MANNING ios in Practice by Bear Cahill Chapter 5 Copyright 2012 Manning Publications brief contents PART 1 GETTING STARTED...1 1 Getting started with ios
More informationMobile Apps 2010 iphone and Android
Mobile Apps 2010 iphone and Android March 9, 2010 Norman McEntire, Founder Servin Corporation - http://servin.com Technology Training for Technology ProfessionalsTM norman.mcentire@servin.com 1 Legal Info
More informationBuilding GUIs with UIKit. Kevin Cathey
Building GUIs with UIKit Kevin Cathey Building GUIs with UIKit acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What is UIKit? acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What
More informationView Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content
View Concepts iphone Application Programming Lecture 4: User Interface Design SDK provide many types of Views to show your content At run-time Views are organized as a tree Chat Wacharamanotham Media Computing
More informationAssignment II: Foundation Calculator
Assignment II: Foundation Calculator Objective The goal of this assignment is to extend the CalculatorBrain from last week to allow inputting variables into the expression the user is typing into the calculator.
More informationCOPYRIGHTED MATERIAL. part I Developing a Professional UI. Chapter 1: Creating a Personal Library. Chapter 2: Advancing with Tableviews
part I Developing a Professional UI Chapter 1: Creating a Personal Library Chapter 2: Advancing with Tableviews Chapter 3: Advancing with Map Kit Chapter 4: Understanding Action Views and Alerts Chapter
More informationCS193E Lecture #3 Categories and Protocols Cocoa Memory Management
CS193E Lecture #3 Categories and Protocols Cocoa Memory Management Winter 2008, Dempsey/Marcos 1 Today s Topics Questions from Assignment 1A or 1B? Categories Protocols Cocoa Memory Management Object life
More informationCoding Conventions Objective-C coding conventions and styling Jens Willy Johannsen
Coding Conventions Objective-C coding conventions and styling 22-06-2012 Jens Willy Johannsen jens@greenerpastures.dk Greener Pastures Change log... 4 Revision 3 (2012-06-22)... 4 Revision 2... 4 Comments...
More informationCOSC$4355/6355$ $Introduction$to$Ubiquitous$Computing$ Exercise$3$ September!17,!2015!
COSC4355/6355 IntroductiontoUbiquitousComputing Exercise3 September17,2015 Objective Inthisexercise,youwilllearnhowtowriteunittestsforyourapplicationandalsohowtouse NSUserDefaults.WewillalsoimplementObjectiveCCcategories*welearntlastweek.
More informationepicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE
epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE + = Prototype iphone ipad Why iphone apps Simplicity Control Speed Revenue Epicurious Defined as a Recipe Utility Cookbook
More informationObjective-C and COCOA Applications
Objective-C and COCOA Applications Fall, 2012 Prof. Massimiliano "Max" Pala pala@nyu.edu Overview X-Code IDE Basics Objective-C Classes Methods Invocations Important Types Memory Management Protocols Exceptions
More informationDeveloping Applications for ios
Developing Applications for ios Lab 2: RPN Calculator App (1 of 3) Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Task 1 Task: Create a new application
More informationCS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding
CS193E Lecture 7 Document-based Applications NSTableView Key-Value Coding Agenda Questions? Review: delegates, MVC Document-based apps Table views Key Value Coding Model, View, Controller Controller Model
More informationAnnouncements. Today s Topics
Announcements Lab 2 is due tonight by 11:59 PM Late policy is 10% of lab total per day late So -7.5 points per day late for lab 2 Labs 3 and 4 are posted on the course website Extensible Networking Platform
More informationAssignment IV: Smashtag Mentions
Assignment IV: Smashtag Mentions Objective In this assignment, you will enhance the Smashtag application that we built in class to give ready-access to hashtags, urls, images and users mentioned in a tweet.
More informationFiles & Archiving. Lecture 8
Files & Archiving Lecture 8 Persistent Data NSUserDefaults Dead simple to use Just one big file Only supports property list types What if you want more features? File Tasks Finding the file path User selected
More informationCS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties
CS193P - Lecture 3 iphone Application Development Custom Classes Object Lifecycle Autorelease Properties 1 Announcements Assignments 1A and 1B due Wednesday 1/13 at 11:59 PM Enrolled Stanford students
More informationIntro to Development for ios. Dave Koziol Arbormoon Software, Inc.
Intro to Development for ios Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (21 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Multiple
More informationCS 47. Beginning iphone Application Development
CS 47 Beginning iphone Application Development Introductions Who, why, which? Shameless Plug: LoudTap Wifi Access (If it works..) SSID: Stanford Username/password: csp47guest Expectations This is a programming
More informationApp SandBox Directory
Data Persistence Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 App SandBox Directory
More informationMobile Development - Lab 2
Mobile Development - Lab 2 Objectives Illustrate the delegation mechanism through examples Use a simple Web service Show how to simply make a hybrid app Display data with a grid layout Delegation pattern
More informationA Vertical Slider for iphone
A Vertical Slider for iphone The UISlider control offers a way to continuously get values from the user within a range of set values. In the Interface Builder library of controls, there is only a horizontal
More informationAbout the Tutorial. Audience. Prerequisites. Copyright & Disclaimer
About the Tutorial ios is a mobile operating system developed and distributed by Apple Inc. It was originally released in 2007 for the iphone, ipod Touch, and Apple TV. ios is derived from OS X, with which
More informationA Mobile Mapping Application
A Mobile Mapping Application MANNING SHELTER ISLAND A Mobile Mapping Application A special edition ebook Copyright 2013 Manning Publications contents about mobile mapping about this ebook v about the authors
More informationStructuring an App Copyright 2013 Apple Inc. All Rights Reserved.
Structuring an App App Development Process (page 30) Designing a User Interface (page 36) Defining the Interaction (page 42) Tutorial: Storyboards (page 47) 29 App Development Process Although the task
More informationView Controller Lifecycle
View Controller Lifecycle View Controllers have a Lifecycle A sequence of messages is sent to them as they progress through it Why does this matter? You very commonly override these methods to do certain
More informationThe MVC Design Pattern
The MVC Design Pattern The structure of iphone applications is based on the Model-View-Controller (MVC) design pattern because it benefits object-oriented programs in several ways. MVC based programs tend
More informationStanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010
Developing Applications for iphone 4, ipod Touch, & ipad Today More Core Data What does the code for the custom NSManagedObject subclasses generated by Xcode look like? Querying for (fetching) objects
More information