SlideShare une entreprise Scribd logo
1  sur  34
iOS Development:
What’s New
April 24, 2013
Topics for Today
• New Objective-C language features
• Storyboard
• UI Customization with UIAppearance
• Some useful stuff I learned this term
Objective-C: New Features
• NSNumber literals
• Boxed expressions
• NSArray & NSDictionary literals
NSNumber Literals
• NSNumber *anInt = [NSNumber numberWithInt: 10];
• NSNumber *aBool =[NSNumber numberWithBool: YES];
• NSNumber *aChar = *NSNumber numberWithChar: ‘z’+;
• Too much typing
• We have all used NSString literals such as @”this”
• NSNumber *aNum = @10;
• NSNumber *aBool = @YES;
• NSNumber *aChar = @’z’;
Boxed Expressions
• @( <an expression> )
• Eg. NSNumber *aDouble = @(2 * pi * r);
• Also works with cstrings, enums
Arrays and Dictionaries
• To create a NSArray or NSDictionary, we need to use factory
methods such as:
• [NSArray arrayWithObjects: obj1, @"abc", obj3, nil];
• [NSDictionary dictionaryWithObjectsAndKeys: obj1, obj2, key1,
key2, nil];
• To access an object:
• [array objectAtIndex: 1];
• *dictionary objectForKey: @”key”+;
• To modify/update/change an object:
• [array replaceObjectAtIndex: 1 withObject: @"new object"];
• [dictionary setObject: @"new Object" forKey: @"key3"];
Container Literals
• NSArray
• @*@”one”, @”two”, @”three”+;
• NSDictionary
• Just like JSON
• @, @”key1” : @”value1”, @”key2” : @”value2”-
• No more confusing factory methods
Demo
Storyboard
What’s Storyboard?
• A .storyboard is basically A huge XML file which contains
XCode Interface Builder information
• Comprised of individual “scenes” (Views + Controllers)
• Transitions/Relationships between scenes are defined by
“segues”
Advantages of Using
Storyboards
• Clearly defined flow
• Less nib file cluttering
• Reduce cluttering even more when you are making an
universal app
• Using segues saves you from writing millions of IBActions with
repetitive push and pop view controller codes.
• Too easy to use
• Build a working UI prototype extremely fast with almost zero
coding
• Storyboard knows about view-controllers, so you can create
more powerful views (eg. Static table view cells, prototype
cells)
Disadvantages of Using
Storyboards
• Impossible to merge storyboard changes
• Solution 1: Don’t work on it at the same time
• Solution 2: Based on program flow, use multiple storyboards
• Not backwards compatible with iOS 4- (also iOS 5 if you are
using features such as embedded segue for container view)
How to Integrate Storyboard in
Your App
• Each project can have a main storyboard set in project settings
• View controllers can also be loaded from storyboard files
programmatically:
• In this way, we can use multiple storyboards with NIBs.
Segues
• A segue defines a visual transition OR relationship between
two view controllers
• Examples of transition segues:
• Push segue (push view controller onto a navigation controller)
• Modal segue (presenting a view controller modally)
• Popover segue (Presenting a UIPopoverController, iPad only)
• Custom segue (subclass UIStoryboardSegue and override the
-perform method to do whatever you want. Can be reused in
Storyboard)
• Examples of relationship segues:
• A empty navigation controller has a relationship segue to its root
view controller
• A container view has a embed segue to its child view controller
Performing Segue
• Define a segue by ctrl-drag from a control (such as UIButton)
to another view controller
• Will be triggered when the specified action is performed on that
control
• Define a segue by ctrl-drag from a view controller to another
view controller
• Segue needs to be triggered manually by calling
–performSegueWithIdentifier:sender:
Pass Data Between Controllers
• Implement prepareForSegue:(UIStoryboardSegue *)sender:(id) in
the view controller that will initiate the segue
• This method is called before a segue is about to be performed
• The UIStoryboardSegue parameter contains the following
properties: identifier, sourceViewController, and
destinationViewController
• Now you can set properties and send messages to these
controllers!
Unwind Segues
• Unwind segue is a segue that jump back to previous scenes
• To unwind from controller B back to controller A:
1. In controller A, create a method that takes a
UIStoryboardSegue as parameter with return type IBAction
2. In storyboard, select controller B, ctrl-drag from a control to the
“Exit” icon at the bottom of the controller
3. Select the method that you defined in B. The unwind segue has
been created.
4. On the left panel of the interface builder, select the unwind
segue and give it an identifier.
5. prepareForSegue:sender: will be called in B, and then the
IBAction method in A will be called
Storyboard: Conclusion
• You can avoid using delegation pattern in some cases if you
use segues
• With iOS 7 introduction due in June, we should start building
new apps with storyboards (and autolayout)
UI Customization with
UIAppearance Protocol
• Customize UIKit objects (eg. UIView, UIButton,…) globally
• Customize specific elements depending on view hierarchy
Demo
Useful iOS Stuff
Singleton Best Practices
• Restricting instantiation of a class to one object only
• Example: ServiceManager
• One object is then shared by many
• Issue: Instantiation in a multi-threaded environment
Basic Singleton
• Not thread-safe
Mutex Lock
• Takes lock every time when you only needs to lock it once.
Expansive.
-Initialize
• If you send any message to the class, singleton object will be
created.
Double-checked Locking
• Check if singleton is instantiated before and after taking lock
• Memory barriers ensures all load and store CPU operations
completes before proceeding
• Doesn’t take lock every time, but still have to pay for
OSMemoryBerrier()
Grand Central Dispatch
• As fast as non-thread safe version
• Similar to double checked locking, but avoid
OSMemoryBarrier() penalty
• Guaranteed run only once
Custom Container View
Controllers
• Embed multiple view controllers in one view controller
• Adding, removing, and transition between child view
controllers
• Its like implementing your own UINavigationController or
UITabBarController
Adding / Removing
Child View Controllers
Transition Between Child View
Controllers
Grand Central Dispatch is
really good, but I don’t have
time to finish the slide!
• Efficient, fast C API
• dispatch_sync, dispatch_async, dispatch_after to queue operations
• dispatch_semaphore, dispatch_group, dispatch_barrier for
synchronization
• You can create your own serial OR concurrent queues with
dispatch_queue_create
• dispatch_apply for concurrent enumeration on an array
• Create “dispatch sources” such as dispatch timers that attach to a
queue and fire periodic events
• Use dispatch_io to do sync/async operations on file descriptors
Thank you!
• Any questions?

Contenu connexe

Tendances

Implementing CATiledLayer
Implementing CATiledLayerImplementing CATiledLayer
Implementing CATiledLayerJesse Collis
 
iOS Beginners Lesson 2
iOS Beginners Lesson 2iOS Beginners Lesson 2
iOS Beginners Lesson 2Calvin Cheng
 
Going Mobile with AIR+Starling
Going Mobile with AIR+StarlingGoing Mobile with AIR+Starling
Going Mobile with AIR+StarlingAmos Laber
 
A Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft OrleansA Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft OrleansUri Goldstein
 
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBoxKobkrit Viriyayudhakorn
 
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...Sébastien Levert
 

Tendances (8)

Mule java part-2
Mule java part-2Mule java part-2
Mule java part-2
 
Implementing CATiledLayer
Implementing CATiledLayerImplementing CATiledLayer
Implementing CATiledLayer
 
iOS Beginners Lesson 2
iOS Beginners Lesson 2iOS Beginners Lesson 2
iOS Beginners Lesson 2
 
Going Mobile with AIR+Starling
Going Mobile with AIR+StarlingGoing Mobile with AIR+Starling
Going Mobile with AIR+Starling
 
A Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft OrleansA Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft Orleans
 
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
 
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
 

Similaire à iOS Development: What's New

Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using XamarinGill Cleeren
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev introVonbo
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone developmentVonbo
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android ossaritasingh19866
 
iPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone DevelopmentiPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone Developmentandriajensen
 
iOS Programming 101
iOS Programming 101iOS Programming 101
iOS Programming 101rwenderlich
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingBitbar
 
iOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkiOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkMiguel de Icaza
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Michael Shrove
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsSubhransu Behera
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - IntroductionSenthil Kumar
 
Hi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextHi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextMugunth Kumar
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1Rich Helton
 

Similaire à iOS Development: What's New (20)

Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using Xamarin
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev intro
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone development
 
Synapse india mobile apps update
Synapse india mobile apps updateSynapse india mobile apps update
Synapse india mobile apps update
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android os
 
iPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone DevelopmentiPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone Development
 
iOS Programming 101
iOS Programming 101iOS Programming 101
iOS Programming 101
 
IOS Storyboards
IOS StoryboardsIOS Storyboards
IOS Storyboards
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App Testing
 
Animation in iOS
Animation in iOSAnimation in iOS
Animation in iOS
 
iOS (7) Workshop
iOS (7) WorkshopiOS (7) Workshop
iOS (7) Workshop
 
iOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkiOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections Talk
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIs
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
Hi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextHi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreText
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
 
iOS: View Controllers
iOS: View ControllersiOS: View Controllers
iOS: View Controllers
 

Dernier

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 

Dernier (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 

iOS Development: What's New

  • 2. Topics for Today • New Objective-C language features • Storyboard • UI Customization with UIAppearance • Some useful stuff I learned this term
  • 3. Objective-C: New Features • NSNumber literals • Boxed expressions • NSArray & NSDictionary literals
  • 4. NSNumber Literals • NSNumber *anInt = [NSNumber numberWithInt: 10]; • NSNumber *aBool =[NSNumber numberWithBool: YES]; • NSNumber *aChar = *NSNumber numberWithChar: ‘z’+; • Too much typing • We have all used NSString literals such as @”this” • NSNumber *aNum = @10; • NSNumber *aBool = @YES; • NSNumber *aChar = @’z’;
  • 5. Boxed Expressions • @( <an expression> ) • Eg. NSNumber *aDouble = @(2 * pi * r); • Also works with cstrings, enums
  • 6. Arrays and Dictionaries • To create a NSArray or NSDictionary, we need to use factory methods such as: • [NSArray arrayWithObjects: obj1, @"abc", obj3, nil]; • [NSDictionary dictionaryWithObjectsAndKeys: obj1, obj2, key1, key2, nil]; • To access an object: • [array objectAtIndex: 1]; • *dictionary objectForKey: @”key”+; • To modify/update/change an object: • [array replaceObjectAtIndex: 1 withObject: @"new object"]; • [dictionary setObject: @"new Object" forKey: @"key3"];
  • 7. Container Literals • NSArray • @*@”one”, @”two”, @”three”+; • NSDictionary • Just like JSON • @, @”key1” : @”value1”, @”key2” : @”value2”- • No more confusing factory methods
  • 10.
  • 11. What’s Storyboard? • A .storyboard is basically A huge XML file which contains XCode Interface Builder information • Comprised of individual “scenes” (Views + Controllers) • Transitions/Relationships between scenes are defined by “segues”
  • 12. Advantages of Using Storyboards • Clearly defined flow • Less nib file cluttering • Reduce cluttering even more when you are making an universal app • Using segues saves you from writing millions of IBActions with repetitive push and pop view controller codes. • Too easy to use • Build a working UI prototype extremely fast with almost zero coding • Storyboard knows about view-controllers, so you can create more powerful views (eg. Static table view cells, prototype cells)
  • 13. Disadvantages of Using Storyboards • Impossible to merge storyboard changes • Solution 1: Don’t work on it at the same time • Solution 2: Based on program flow, use multiple storyboards • Not backwards compatible with iOS 4- (also iOS 5 if you are using features such as embedded segue for container view)
  • 14. How to Integrate Storyboard in Your App • Each project can have a main storyboard set in project settings • View controllers can also be loaded from storyboard files programmatically: • In this way, we can use multiple storyboards with NIBs.
  • 15. Segues • A segue defines a visual transition OR relationship between two view controllers • Examples of transition segues: • Push segue (push view controller onto a navigation controller) • Modal segue (presenting a view controller modally) • Popover segue (Presenting a UIPopoverController, iPad only) • Custom segue (subclass UIStoryboardSegue and override the -perform method to do whatever you want. Can be reused in Storyboard) • Examples of relationship segues: • A empty navigation controller has a relationship segue to its root view controller • A container view has a embed segue to its child view controller
  • 16. Performing Segue • Define a segue by ctrl-drag from a control (such as UIButton) to another view controller • Will be triggered when the specified action is performed on that control • Define a segue by ctrl-drag from a view controller to another view controller • Segue needs to be triggered manually by calling –performSegueWithIdentifier:sender:
  • 17.
  • 18. Pass Data Between Controllers • Implement prepareForSegue:(UIStoryboardSegue *)sender:(id) in the view controller that will initiate the segue • This method is called before a segue is about to be performed • The UIStoryboardSegue parameter contains the following properties: identifier, sourceViewController, and destinationViewController • Now you can set properties and send messages to these controllers!
  • 19. Unwind Segues • Unwind segue is a segue that jump back to previous scenes • To unwind from controller B back to controller A: 1. In controller A, create a method that takes a UIStoryboardSegue as parameter with return type IBAction 2. In storyboard, select controller B, ctrl-drag from a control to the “Exit” icon at the bottom of the controller 3. Select the method that you defined in B. The unwind segue has been created. 4. On the left panel of the interface builder, select the unwind segue and give it an identifier. 5. prepareForSegue:sender: will be called in B, and then the IBAction method in A will be called
  • 20. Storyboard: Conclusion • You can avoid using delegation pattern in some cases if you use segues • With iOS 7 introduction due in June, we should start building new apps with storyboards (and autolayout)
  • 21. UI Customization with UIAppearance Protocol • Customize UIKit objects (eg. UIView, UIButton,…) globally • Customize specific elements depending on view hierarchy
  • 22. Demo
  • 24. Singleton Best Practices • Restricting instantiation of a class to one object only • Example: ServiceManager • One object is then shared by many • Issue: Instantiation in a multi-threaded environment
  • 25. Basic Singleton • Not thread-safe
  • 26. Mutex Lock • Takes lock every time when you only needs to lock it once. Expansive.
  • 27. -Initialize • If you send any message to the class, singleton object will be created.
  • 28. Double-checked Locking • Check if singleton is instantiated before and after taking lock • Memory barriers ensures all load and store CPU operations completes before proceeding • Doesn’t take lock every time, but still have to pay for OSMemoryBerrier()
  • 29. Grand Central Dispatch • As fast as non-thread safe version • Similar to double checked locking, but avoid OSMemoryBarrier() penalty • Guaranteed run only once
  • 30. Custom Container View Controllers • Embed multiple view controllers in one view controller • Adding, removing, and transition between child view controllers • Its like implementing your own UINavigationController or UITabBarController
  • 31. Adding / Removing Child View Controllers
  • 32. Transition Between Child View Controllers
  • 33. Grand Central Dispatch is really good, but I don’t have time to finish the slide! • Efficient, fast C API • dispatch_sync, dispatch_async, dispatch_after to queue operations • dispatch_semaphore, dispatch_group, dispatch_barrier for synchronization • You can create your own serial OR concurrent queues with dispatch_queue_create • dispatch_apply for concurrent enumeration on an array • Create “dispatch sources” such as dispatch timers that attach to a queue and fire periodic events • Use dispatch_io to do sync/async operations on file descriptors
  • 34. Thank you! • Any questions?