iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode

iOS: XCode and Interface Builder

Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

Tommy MacWilliam [email protected]

March 7, 2012

Today iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder

I

Objective-C Review

I

XCode

I

Outlets and Actions

Outlets and Actions

I

Delegates and Protocols

Delegates and Protocols

I

Tic-Tac-Toe

Tic-Tac-Toe

Classes iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review

I

@interface: .h files

XCode

I

Interface Builder

I

Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

declare class methods and properties @class Something to use other classes

@implementation: .m files I I

define class methods and synthesize properties #import “Something.h” to use other classes

Classes iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

-: instance methods, sent to objects (e.g. init)

I

+: class methods, sent to class, not object (e.g. alloc)

Properties iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode

I

I

Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

@property (nonatomic, assign) int foo;

I

declare new property, specify how values are assigned

@synthesize foo = _foo; I

generate getters/setters for property

Message Passing iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder

I

- (id)init

I I

- (id)initWithName:(NSString*)name - (id)initWithName:(NSString*)name age:(int)age

I

[object initWithName:@”name”];

Outlets and Actions Delegates and Protocols Tic-Tac-Toe

GDB iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder

I

create breakpoint by clicking on line number

I

next: continue line-by-line

I

step: go into a called function

Outlets and Actions

I

continue: resume execution until next breakpoint

Delegates and Protocols

I

print or mouse over variable to see value

Tic-Tac-Toe

Objective-C and GDB iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

GDB

Interface Builder iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder

I

File Inspector: nib options

I

Quick Help: view documentation for the selected UIView

I

Identity Inspector: modify object properties

Outlets and Actions

I

Attributes Inspector: customize the selected UIView

Delegates and Protocols

I

Size Inspector: change placement/size of UIView

Tic-Tac-Toe

I

Connections Inspector: manage outlets/actions

Interface Builder iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review

I

File’s Owner: object that loads nib

I

First Responder: UIView currently in focus and responding to input

Outlets and Actions

I

App Delegate: responsible for loading, resuming, etc.

Delegates and Protocols

I

Window: container for UIView

XCode Interface Builder

Tic-Tac-Toe

Outlets iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

IBOutlet tells XCode the object represents something in IB I I

NOT the type of the object, just a flag @property (nonatomic, strong) IBOutlet UIButton* button;

Using Outlets iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode

I

define UIView properties in @interface

Interface Builder

I

synthesize UIView properties in @implementation

Outlets and Actions

I

connect Objects in Interface Builder

Delegates and Protocols Tic-Tac-Toe

Connecting Outlets iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review

I

select placeholder where property is defined (File’s Owner or App Delegate)

I

Ctrl-Click and drag to UIView

I

select name of outlet

I

???

I

profit!

XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

Actions iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

IBAction tells XCode the method is used by something in IB I

equivalent to the void type, so all methods are void

Connecting Actions iOS: XCode and Interface Builder Tommy MacWilliam

I

select UIView to fire callback for, open Connections Inspector

I

Ctrl-Click callback, drag to placeholder where method is defined (File’s Owner or App Delegate)

Outlets and Actions

I

select name of method

Delegates and Protocols

I

???

Tic-Tac-Toe

I

profit!

Objective-C Review XCode Interface Builder

Outlets and Actions iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

TextFieldExample

Delegate iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode

I

define object to handle actions

Interface Builder

I

delegate object implements a protocol

Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

guarantees definitions for methods exist

Protocol iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

@protocol SomeProtocol - (void)something - (int)calculateSomething:(int) @end

UITextFieldDelegate iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review

I

textFieldShouldReturn: “done” button pressed

I

textFieldShouldBeginEditing: user about to edit text

I

textFieldShouldEndEditing: text field about to lose focus

XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

Using Protocols and Delegates iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

BetterTextFieldExample

I

UtilityApp

Putting it All Together iOS: XCode and Interface Builder Tommy MacWilliam Objective-C Review XCode Interface Builder Outlets and Actions Delegates and Protocols Tic-Tac-Toe

I

TicTacToe I I

our first of many award-winning apps follow along!

iOS: XCode and Interface Builder - cs164

Mar 7, 2012 - +: class methods, sent to class, not object (e.g. alloc). Page 5. iOS: XCode and Interface. Builder. Tommy. MacWilliam. Objective-C. Review.

75KB Sizes 4 Downloads 279 Views

Recommend Documents

iOS: XCode and Interface Builder - cs164
Mar 7, 2012 - iOS: XCode and Interface. Builder. Tommy. MacWilliam. Objective-C. Review. XCode. Interface. Builder. Outlets and. Actions. Delegates and.

iOS: Evil Hangman Walkthrough - cs164
Mar 21, 2012 - Property Lists. Equivalence. Classes. Protocols. Transitioning. Between. Views. Settings. iOS: Evil Hangman Walkthrough. CS164 Walkthrough ...

iOS: Evil Hangman Walkthrough - cs164
Mar 21, 2012 - for each word in set: determine equivalence class for word; add word to equivalence class; determine largest equivalence class; remove all ...

ios human interface guidelines pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

Untitled - cs164
High Performance MySQL. Page 12. partitioning. High Performance MySQL. Page 13. high availability. High Performance MySQL. Page 14. realtime apps ...

Specification - cs164
need a Mac for the course until Mon 3/19, but Xcode comes with iOS Simulator, which might prove handy for testing in the short term. If you do have a Mac, know ...

Specification - cs164
Computer Science 164: Mobile Software Engineering. Harvard College .... Log into your Bitbucket account and create a new, private repo as follows: □ Select ...

Syllabus - cs164
Computer Science 164: Mobile Software Engineering ... Description .... intend to use outside of the course (e.g., for a job) must be approved by the staff. ... Administrative Board and the outcome for some student is Admonish, Probation, ...

Download iOS 10 Programming Fundamentals with Swift: Swift, Xcode, and Cocoa Basics Full Books
iOS 10 Programming Fundamentals with Swift: Swift, Xcode, and Cocoa Basics Download at => https://pdfkulonline13e1.blogspot.com/1491970073 iOS 10 Programming Fundamentals with Swift: Swift, Xcode, and Cocoa Basics pdf download, iOS 10 Programming

Evil Hangman - cs164
thereafter, you might also want to sign up for the iOS Developer Program at ... Because the course is part of the iOS Developer University Program, you will be ...

Mobile Software Engineering - cs164
singletons, factories, observers, ... Page 23. unit testing. PHPUnit, Selenium, ... Page 24. UX. Page 25. performance latency, caching, ... Page 26. source control git, subversion. Page 27. IDEs. Xcode, ... Page 28. PHP frameworks. CodeIgniter. Page

Specification - cs164
Fri. 2/3. Proposal. 2/6. Design Doc, Style Guide. 2/10. Beta. 2/24. Release ... or otherwise exposed) or lifting material from a book, website, or other ... Help is available throughout the week at http://help.cs164.net/, and we'll do our best to res

Untitled - cs164
web hosts. Bluehost. DreamHost. Go Daddy. Host Gator pair Networks ... Page 3. VPSes. DreamHost. Go Daddy. Host Gator. Linode pair Networks. Slicehost.

design patterns - cs164
sections labs design reviews, code reviews, office hours alphas new release cycle. Page 5. new release cycle. Page 6. workload. Page 7. project 1. Page 8 ...

Evil Hangman - cs164
thereafter, you might also want to sign up for the iOS Developer Program at ... Because the course is part of the iOS Developer University Program, you will be ...

User Interface Best Practices for Building iOS DPS Apps - Adobe
UI Best Practices for iOS Apps. Adobe Systems Incorporated. Page 4 ... Display calls to action within free magazine content by using a digital blow-in ... This way, if the user happened to open Newsstand when they aren't connected (such as ...