SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
WAKE UP

Sunday, January 15, 12
Sunday, January 15, 12
HIG
                          (HUMAN INTERFACE GUIDELINE)



    • Прегърни               Платформата и Хюман Интерфейс Принципите

    • Ясни               дефиниции:

              -   какво?

              -   на кого?



Sunday, January 15, 12
ПРЕЖИВЯВАНЕТО НА
                            ПОТРЕБИТЕЛЯ

    • поведение

    • изглед

    • начало             и край

    • употреба             на бутони

    • употреба             на жестове


Sunday, January 15, 12
RESOURCES
                         Navigation of ViewControllers




Sunday, January 15, 12
RESOURCES

         • images, icons

         • Has           90° corners

         • shine          or gloss

         • not           use alpha transparency

         • not           include a drop shadow


Sunday, January 15, 12
Sunday, January 15, 12
CUSTOM ARTWORK




Sunday, January 15, 12
APPLICATION ICONS

                                   iPhone 2G/3G          iPhone 4G                      iPad

                                      57 x 57             114 x 114                 72 x 72
                App icon             Icon.png           Icon@2x.png              Icon~ipad.png

                                    512 x 512
                Awtwork                                        -                          -
                               iTunesArtwork/.png/

                                    320 x 480            640 x 960                320 x 480
             Loading image
                                   Default.png        Default@2x.png           Default~ipad.png
                                      29 x 29              29 x 29                    29 x 29
              Settings icon     Icon-settings.png /   Icon-settings.png /        Icon-settings.png /
                                  Icon-Small.png        Icon-Small.png             Icon-Small.png
                                       29 x 29              58 x 58                   64 x 64
            Documents icon
                                    Icon-doc.png       Icon-doc@2x.png           Icon-doc~ipad.png
                                                                                    50 X 50
            Spotlight search             -                     -            Icon-spot~ipad.png/Icon-
                                                                                  Small-50.png



Sunday, January 15, 12
IMPORT IN XCODE




Sunday, January 15, 12
THE MEMORY MANAGEMENT




Sunday, January 15, 12
АДРЕСИ И СТОЙНОСТИ


                           assign = store address




Sunday, January 15, 12
RETAINCOUNT




Sunday, January 15, 12
Copying Collections

                                  COPYING
                              DEEP VS SHALLOW
                   There are two kinds of object copying: shallow copies and deep copies. The normal copy is a shallow copy
                   that produces a new collection that shares ownership of the objects with the original. Deep copies create
                   new objects from the originals and add those to the new collection. This difference is illustrated by Figure
                   1.

                      objects retain deep copies
                   Figure 1 Shallow copies and                                  objects copy
                   Array 1                       Array 2            Array 1                       Array 2

                      0           Object A          0                  0          Object A           0           Object A


                      1           Object B          1                  1          Object B           1          Object B


                      2           Object C          2                  2          Object C           2          Object C


                      3           Object D          3                  3          Object D           3          Object D


                      4           Object E          4                  4          Object E           4          Object E



                               Shallow copy                                                  Deep copy




 NSDictionary *shallowCopyDict=[[NSDictionary alloc]                   NSArray *deepCopyArray=[[NSArray alloc] initWithArray:
      Shallow Copies
 initWithDictionary:someDictionary copyItems: NO];                     someArray copyItems: YES];



                       There are a number of ways to make a shallow copy of a collection. When you create a shallow copy, the
Sunday, January 15, 12 objects in the original collection are sent a retain message and the pointers are copied to the new collection.
RETAIN / RELEASE
                   Application memory management is the process of allocating memory during your program’s runtime, using
                   it, and freeing it when you are done with it. A well-‐written program uses as little memory as possible. In
                   Objective-‐C, it can also be seen as a way of distributing ownership of limited memory resources among many
                   pieces of data and code. When you have finished working through this guide, you will have the knowledge
                   you need to manage your application’s memory by explicitly managing the life cycle of objects and freeing
                   them when they are no longer needed.

                   Although memory management is typically considered at the level of an individual object, your goal is actually
               A well-written program uses as little memory as possible.
                   to manage object graphs. You want to make sure that you have no more objects in memory than you actually
                   need.


                                  Class A           Class B                  Class A             Class B




                                alloc/init          retain                  release              release



                                                                                                                      Destroyed
                    Retain count = 1                2              2         2                    1           0


                                                          copy                                                        Destroyed

                                                                                       1                      0
                                                         Class C
                                                                                       release


                                                                                       Class C




Sunday, January 15, 12
have cyclical references—that is, they have a strong reference to each other (either directly
                            chain of other objects each with a strong reference to the next leading back to the first).

                            The object relationships shown in Figure 1 (page 17) illustrate a potential retain cycle. The D
                            has a Page object for each page in the document. Each Page object has a property that kee


                         RETAIN CYCLES
                            document it is in. If the Document object has a strong reference to the Page object and the
                            a strong reference to the Document object, neither object can ever be deallocated. The Docu
                            count cannot become zero until the Page object is released, and the Page object won’t be r
                            Document object is deallocated.

                            Figure 1        An illustration of cyclical references

                            Document



                                         page



                                                       don’t
                            Page            retain     retain



                                         parent
                                       paragraph




                            Paragraph       retain     don’t
                                                       retain


                                         text
                                        parent




Sunday, January 15, 12      Use Weak References to Avoid Retain Cycles
THE MEMORY MANAGEMENT




Sunday, January 15, 12
My
                              W
                               AY
      THE MEMORY MANAGEMENT




Sunday, January 15, 12
MEMORY MANAGEMENT
                                    objects to be created
                                          /UIView/



                             0               0               0
                            View1          View2            View3

                 subviews    nil             nil             nil
                /NSArray/


            +1                          +1                   0
                             +1                             View4
                            retain   addSubview
           alloc
                         /ownership/                         nil


Sunday, January 15, 12
MEMORY MANAGEMENT
                         UIView    *....= [[[UIView alloc] init] autorelease];



                                  +1          +1            +1

                                       1            1             1
                                   View1           View2         View3


                                       nil          nil           nil



                                                                         +1
            +1                               +1                   1
                                  +1                           View4
                                 retain   addSubview
           alloc
                              /ownership/                         nil


Sunday, January 15, 12
MEMORY MANAGEMENT
                Form view hierarchy
                                                             +1
                                                 +1                             +1
                                            retain                     retain
                                  1                          3                          2
                             View1                      View2                        View3

                                                                                                           n
                          View2       nil            View3       nil                    nil         re tai

                                                                                               +1
                                                                       re
                                                                         ta
                                                                           in
            +1                          +1                                              2
                             +1                                                      View4
                            retain   addSubview
           alloc
                         /ownership/                                            View2         nil


Sunday, January 15, 12
MEMORY MANAGEMENT
                         Set view1 as a property /UIVIewController/
    Controller           @property(nonatomic, retain)UIView *view1;



                                       +1
                         +1
                                   3                 3                  2
                              View1             View2                 View3


                           View2       nil   View3       nil            nil




            +1                          +1                              2
                             +1                                       View4
                            retain   addSubview
           alloc
                         /ownership/                            View2         nil


Sunday, January 15, 12
MEMORY MANAGEMENT                               @property (nonatomic, retain)
                         @property (nonatomic, assign)
                         id delegate;                              id delegate;
                                          assign / weak            retain / strong
    Controller
                                            delegate                     delegate


                                                                    +1
                                      3                        4                       2
                                 View1                    View2                     View3


                              View2       nil          View3       nil                 nil




            +1                             +1                                          2
                                +1                                                  View4
                               retain   addSubview
           alloc
                            /ownership/                                        View2         nil


Sunday, January 15, 12
MEMORY MANAGEMENT
                                           Controller kills View1
    Controller
                                           delegate                     delegate

    [view2 removeFromSuperview];
                                                                        retain

                                    3                         3                          2
                                   View1                 View2                      View3
                                                 -1
                                    nil               View3       nil                    nil



                                                                        re
                                                                          ta
                                                                            in
             -1                                           -1                             2
                                    -1                                              View4

        dealloc               release           removeFrom                       View2         nil
                                                 Superview
Sunday, January 15, 12
MEMORY MANAGEMENT
                                     assign / weak            retain / strong
    Controller
                                       delegate                     delegate

                                     -1
                         -1                                         retain

                               1                          3                          2
                              View1                  View2                      View3
  - (void)dealloc {
      [view1 release];
  }                            nil                View3       nil                    nil



                                                                    re
                                                                      ta
                                                                        in
             -1                                       -1                             2
                               -1                                               View4

        dealloc           release            removeFrom                      View2         nil
                                              Superview
Sunday, January 15, 12
MEMORY MANAGEMENT
                                   assign / weak            retain / strong
      message to nil                 delegate                     delegate
         is legal
                                                                  retain
             autorelease
                            nil                         3                          2
                                                   View2                      View3


                             nil                View3       nil                    nil



                                                                  re
                                                                    ta
                                                                      in
       if ([_delegate respondsToSelector:                                          2
                @selector(requiredMethod)]) {                                 View4
              [_delegate requiredMethod];
          }
                                                                           View2         nil


Sunday, January 15, 12
MEMORY MANAGEMENT
                                      Kill View4?
                                                      retain / strong
                                                             delegate


                         -1               -1                 retain

                               1                  2                      2
                              View4            View2                    View3


                               nil        View3        nil               nil




             -1               -1          -1
        dealloc          release      removeFrom
                                       Superview
Sunday, January 15, 12
RETAIN CYCLE

    LEAK!?!                                          retain

                                                     delegate


                                                     retain

                                           2                     2
                                      View2                     View3


                                   View3       nil               nil




                         Няма останали *указатели към обектите
Sunday, January 15, 12
MEMORY MANAGEMENT
                                           Kill View4?
                                                           retain / strong
         [subviews <#cleanUpDelegates#>]
                                                                  delegate
                                                                    -1
                                                                  retain

                                 2                     3                      2
                            View4                   View2                    View3


                         View2       nil       View3        nil               nil




             -1             -1                 -1
        dealloc          release           removeFrom
                                            Superview
Sunday, January 15, 12
MEMORY MANAGEMENT
                                        Kill View4?


                                   -1                    -1                 -1

                            1                     1                  1
                           View4                 View2              View3


                             nil                  nil                nil




             -1            -1               -1                They will be autoreleased
                                                              or released in dealloc
        dealloc          release        removeFrom                  of the owner
                                         Superview
Sunday, January 15, 12
MEMORY MANAGEMENT

                                 autorelease

                          0           0         0
                         View4       View2     View3


                          nil         nil       nil




Sunday, January 15, 12
ПРИМЕРИ

     if   ([defaults objectForKey:@"actorsPlayed"] != nil) {
     !    !     [_actorsPlayed release];
     !    !     _actorsPlayed = nil;
     !    !     _actorsPlayed = [[defaults objectForKey:@"actorsPlayed"] retain];
     !    }




    NSDictionary *currRecord = [[NSDictionary alloc]
    ! !      !   !   !   !    !   !   initWithObjects:[NSArray arrayWithObjects:
                                      [NSNumber numberWithInt:highScore], _game.playerName,
                                      nil]
    ! !      !   !   !   !    !   !   forKeys:[NSArray arrayWithObjects:@"score", @"name",         Array autorelease
    nil]];




   NSMutableArray *diffHighScore = [[NSMutableArray alloc] initWithArray:[_localHiscores objectForKey:key]];




Sunday, January 15, 12
NAVIGATION CONTROLLER
                         Основи




Sunday, January 15, 12
NAVIGATION CONTROLLER
                         CHAPTER 3
                         Navigation Controllers




                         Figure 3-3        The navigation stack

                             UINavigationController
                                                                            Navigation stack
                               viewControllers
                                      (NSArray)
                                                                              View controller

                              topViewController


                           visibleViewController




                         Your main responsibility is to push new view controllers onto the stack in response to user actions. Each v
                         controller you push on the navigation stack is responsible for presenting some portion of your applicat
Sunday, January 15, 12
                         data. Typically, when the user selects an item in the currently visible view, you create a new view contro
NAVIGATION CONTROLLER
                                   NSArray of ViewControllers

                         Root VC    VC2       VC3     Visible   Top

                           0          1        2        3       3
    •   popToRootViewControllerAnimated:<#(BOOL)#>

    •   popToViewController:<#(UIViewController *)#> animated:<#(BOOL)#>

    •   popViewControllerAnimated:<#(BOOL)#>

    •   pushViewController:<#(UIViewController *)#> animated:<#(BOOL)#>

Sunday, January 15, 12
XCODE




Sunday, January 15, 12

Más contenido relacionado

La actualidad más candente

Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
Whymca
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
DataArt
 

La actualidad más candente (20)

Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Management
 
Lecture 3-ARC
Lecture 3-ARCLecture 3-ARC
Lecture 3-ARC
 
Hooks and Events in Drupal 8
Hooks and Events in Drupal 8Hooks and Events in Drupal 8
Hooks and Events in Drupal 8
 
Events: The Object Oriented Hook System.
Events: The Object Oriented Hook System.Events: The Object Oriented Hook System.
Events: The Object Oriented Hook System.
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
Method Swizzling with Objective-C
Method Swizzling with Objective-CMethod Swizzling with Objective-C
Method Swizzling with Objective-C
 
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginDrupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
 
The state of hooking into Drupal - DrupalCon Dublin
The state of hooking into Drupal - DrupalCon DublinThe state of hooking into Drupal - DrupalCon Dublin
The state of hooking into Drupal - DrupalCon Dublin
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
50 jquery
50 jquery50 jquery
50 jquery
 
A practical intro to BabylonJS
A practical intro to BabylonJSA practical intro to BabylonJS
A practical intro to BabylonJS
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Design Summit - Navigating the ManageIQ Object Model - Brad Ascar
Design Summit - Navigating the ManageIQ Object Model - Brad AscarDesign Summit - Navigating the ManageIQ Object Model - Brad Ascar
Design Summit - Navigating the ManageIQ Object Model - Brad Ascar
 
Actor Model Akka Framework
Actor Model Akka FrameworkActor Model Akka Framework
Actor Model Akka Framework
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScript
 
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 

Destacado

iOS Tips + ModalVC
iOS Tips + ModalVCiOS Tips + ModalVC
iOS Tips + ModalVC
Marian Ignev
 
iOS UI Table Views
iOS UI Table ViewsiOS UI Table Views
iOS UI Table Views
Marian Ignev
 

Destacado (9)

PaaS бъдещето на креативния програмист!
PaaS бъдещето на креативния програмист!PaaS бъдещето на креативния програмист!
PaaS бъдещето на креативния програмист!
 
iOS Development - Intro
iOS Development - IntroiOS Development - Intro
iOS Development - Intro
 
The messy lecture
The messy lectureThe messy lecture
The messy lecture
 
Какво е Startup?
Какво е Startup?Какво е Startup?
Какво е Startup?
 
iOS Tips + ModalVC
iOS Tips + ModalVCiOS Tips + ModalVC
iOS Tips + ModalVC
 
iOS UI Table Views
iOS UI Table ViewsiOS UI Table Views
iOS UI Table Views
 
iOS Views
iOS ViewsiOS Views
iOS Views
 
Step-by-Step Parse Migration
Step-by-Step Parse MigrationStep-by-Step Parse Migration
Step-by-Step Parse Migration
 
iOS Architecture and MVC
iOS Architecture and MVCiOS Architecture and MVC
iOS Architecture and MVC
 

Similar a iOS Memory management & Navigation

Objective-C: a gentle introduction
Objective-C: a gentle introductionObjective-C: a gentle introduction
Objective-C: a gentle introduction
Gabriele Petronella
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineering
Saswat Padhi
 
OO and Rails...
OO and Rails... OO and Rails...
OO and Rails...
adzdavies
 

Similar a iOS Memory management & Navigation (20)

Objective-C: a gentle introduction
Objective-C: a gentle introductionObjective-C: a gentle introduction
Objective-C: a gentle introduction
 
Jailbreak Detector Detector
Jailbreak Detector DetectorJailbreak Detector Detector
Jailbreak Detector Detector
 
How the hell do I run Docker in production, and will it scale?
How the hell do I run Docker in production, and will it scale?How the hell do I run Docker in production, and will it scale?
How the hell do I run Docker in production, and will it scale?
 
iPhone Programming [2/17] : Introduction to iOS Programming
iPhone Programming [2/17] : Introduction to iOS ProgrammingiPhone Programming [2/17] : Introduction to iOS Programming
iPhone Programming [2/17] : Introduction to iOS Programming
 
Docker experience @inbotapp
Docker experience @inbotappDocker experience @inbotapp
Docker experience @inbotapp
 
Groovy there's a docker in my application pipeline
Groovy there's a docker in my application pipelineGroovy there's a docker in my application pipeline
Groovy there's a docker in my application pipeline
 
OSMC 2017 | Groovy There is a Docker in my Dashing Pipeline by Kris Buytaert
OSMC 2017 | Groovy There is a Docker in my Dashing Pipeline by Kris Buytaert OSMC 2017 | Groovy There is a Docker in my Dashing Pipeline by Kris Buytaert
OSMC 2017 | Groovy There is a Docker in my Dashing Pipeline by Kris Buytaert
 
PowerPoint Presentation
PowerPoint PresentationPowerPoint Presentation
PowerPoint Presentation
 
Implementation of an agile process for multiple teams using SVN
Implementation of an agile process for multiple teams using SVNImplementation of an agile process for multiple teams using SVN
Implementation of an agile process for multiple teams using SVN
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineering
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
OO and Rails...
OO and Rails... OO and Rails...
OO and Rails...
 
How the hell do I run my microservices in production, and will it scale?
How the hell do I run my microservices in production, and will it scale?How the hell do I run my microservices in production, and will it scale?
How the hell do I run my microservices in production, and will it scale?
 
How the hell do I run my microservices in production, and will it scale?
How the hell do I run my microservices in production, and will it scale?How the hell do I run my microservices in production, and will it scale?
How the hell do I run my microservices in production, and will it scale?
 
How the hell do I run my microservices in production, and will it scale?
How the hell do I run my microservices in production, and will it scale?How the hell do I run my microservices in production, and will it scale?
How the hell do I run my microservices in production, and will it scale?
 
A quick overview of why to use and how to set up iPython notebooks for research
A quick overview of why to use and how to set up iPython notebooks for researchA quick overview of why to use and how to set up iPython notebooks for research
A quick overview of why to use and how to set up iPython notebooks for research
 
Android Bootstrap
Android BootstrapAndroid Bootstrap
Android Bootstrap
 
Continuous Delivery of (y)our infrastructure.
Continuous Delivery of (y)our infrastructure.Continuous Delivery of (y)our infrastructure.
Continuous Delivery of (y)our infrastructure.
 
delivering applications with zc.buildout and a distributed model - Plone Conf...
delivering applications with zc.buildout and a distributed model - Plone Conf...delivering applications with zc.buildout and a distributed model - Plone Conf...
delivering applications with zc.buildout and a distributed model - Plone Conf...
 
What's new in CQ 5.3? Top 10 features.
What's new in CQ 5.3? Top 10 features.What's new in CQ 5.3? Top 10 features.
What's new in CQ 5.3? Top 10 features.
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

iOS Memory management & Navigation

  • 3. HIG (HUMAN INTERFACE GUIDELINE) • Прегърни Платформата и Хюман Интерфейс Принципите • Ясни дефиниции: - какво? - на кого? Sunday, January 15, 12
  • 4. ПРЕЖИВЯВАНЕТО НА ПОТРЕБИТЕЛЯ • поведение • изглед • начало и край • употреба на бутони • употреба на жестове Sunday, January 15, 12
  • 5. RESOURCES Navigation of ViewControllers Sunday, January 15, 12
  • 6. RESOURCES • images, icons • Has 90° corners • shine or gloss • not use alpha transparency • not include a drop shadow Sunday, January 15, 12
  • 9. APPLICATION ICONS iPhone 2G/3G iPhone 4G iPad 57 x 57 114 x 114 72 x 72 App icon Icon.png Icon@2x.png Icon~ipad.png 512 x 512 Awtwork - - iTunesArtwork/.png/ 320 x 480 640 x 960 320 x 480 Loading image Default.png Default@2x.png Default~ipad.png 29 x 29 29 x 29 29 x 29 Settings icon Icon-settings.png / Icon-settings.png / Icon-settings.png / Icon-Small.png Icon-Small.png Icon-Small.png 29 x 29 58 x 58 64 x 64 Documents icon Icon-doc.png Icon-doc@2x.png Icon-doc~ipad.png 50 X 50 Spotlight search - - Icon-spot~ipad.png/Icon- Small-50.png Sunday, January 15, 12
  • 10. IMPORT IN XCODE Sunday, January 15, 12
  • 12. АДРЕСИ И СТОЙНОСТИ assign = store address Sunday, January 15, 12
  • 14. Copying Collections COPYING DEEP VS SHALLOW There are two kinds of object copying: shallow copies and deep copies. The normal copy is a shallow copy that produces a new collection that shares ownership of the objects with the original. Deep copies create new objects from the originals and add those to the new collection. This difference is illustrated by Figure 1. objects retain deep copies Figure 1 Shallow copies and objects copy Array 1 Array 2 Array 1 Array 2 0 Object A 0 0 Object A 0 Object A 1 Object B 1 1 Object B 1 Object B 2 Object C 2 2 Object C 2 Object C 3 Object D 3 3 Object D 3 Object D 4 Object E 4 4 Object E 4 Object E Shallow copy Deep copy NSDictionary *shallowCopyDict=[[NSDictionary alloc] NSArray *deepCopyArray=[[NSArray alloc] initWithArray: Shallow Copies initWithDictionary:someDictionary copyItems: NO]; someArray copyItems: YES]; There are a number of ways to make a shallow copy of a collection. When you create a shallow copy, the Sunday, January 15, 12 objects in the original collection are sent a retain message and the pointers are copied to the new collection.
  • 15. RETAIN / RELEASE Application memory management is the process of allocating memory during your program’s runtime, using it, and freeing it when you are done with it. A well-‐written program uses as little memory as possible. In Objective-‐C, it can also be seen as a way of distributing ownership of limited memory resources among many pieces of data and code. When you have finished working through this guide, you will have the knowledge you need to manage your application’s memory by explicitly managing the life cycle of objects and freeing them when they are no longer needed. Although memory management is typically considered at the level of an individual object, your goal is actually A well-written program uses as little memory as possible. to manage object graphs. You want to make sure that you have no more objects in memory than you actually need. Class A Class B Class A Class B alloc/init retain release release Destroyed Retain count = 1 2 2 2 1 0 copy Destroyed 1 0 Class C release Class C Sunday, January 15, 12
  • 16. have cyclical references—that is, they have a strong reference to each other (either directly chain of other objects each with a strong reference to the next leading back to the first). The object relationships shown in Figure 1 (page 17) illustrate a potential retain cycle. The D has a Page object for each page in the document. Each Page object has a property that kee RETAIN CYCLES document it is in. If the Document object has a strong reference to the Page object and the a strong reference to the Document object, neither object can ever be deallocated. The Docu count cannot become zero until the Page object is released, and the Page object won’t be r Document object is deallocated. Figure 1 An illustration of cyclical references Document page don’t Page retain retain parent paragraph Paragraph retain don’t retain text parent Sunday, January 15, 12 Use Weak References to Avoid Retain Cycles
  • 18. My W AY THE MEMORY MANAGEMENT Sunday, January 15, 12
  • 19. MEMORY MANAGEMENT objects to be created /UIView/ 0 0 0 View1 View2 View3 subviews nil nil nil /NSArray/ +1 +1 0 +1 View4 retain addSubview alloc /ownership/ nil Sunday, January 15, 12
  • 20. MEMORY MANAGEMENT UIView *....= [[[UIView alloc] init] autorelease]; +1 +1 +1 1 1 1 View1 View2 View3 nil nil nil +1 +1 +1 1 +1 View4 retain addSubview alloc /ownership/ nil Sunday, January 15, 12
  • 21. MEMORY MANAGEMENT Form view hierarchy +1 +1 +1 retain retain 1 3 2 View1 View2 View3 n View2 nil View3 nil nil re tai +1 re ta in +1 +1 2 +1 View4 retain addSubview alloc /ownership/ View2 nil Sunday, January 15, 12
  • 22. MEMORY MANAGEMENT Set view1 as a property /UIVIewController/ Controller @property(nonatomic, retain)UIView *view1; +1 +1 3 3 2 View1 View2 View3 View2 nil View3 nil nil +1 +1 2 +1 View4 retain addSubview alloc /ownership/ View2 nil Sunday, January 15, 12
  • 23. MEMORY MANAGEMENT @property (nonatomic, retain) @property (nonatomic, assign) id delegate; id delegate; assign / weak retain / strong Controller delegate delegate +1 3 4 2 View1 View2 View3 View2 nil View3 nil nil +1 +1 2 +1 View4 retain addSubview alloc /ownership/ View2 nil Sunday, January 15, 12
  • 24. MEMORY MANAGEMENT Controller kills View1 Controller delegate delegate [view2 removeFromSuperview]; retain 3 3 2 View1 View2 View3 -1 nil View3 nil nil re ta in -1 -1 2 -1 View4 dealloc release removeFrom View2 nil Superview Sunday, January 15, 12
  • 25. MEMORY MANAGEMENT assign / weak retain / strong Controller delegate delegate -1 -1 retain 1 3 2 View1 View2 View3 - (void)dealloc { [view1 release]; } nil View3 nil nil re ta in -1 -1 2 -1 View4 dealloc release removeFrom View2 nil Superview Sunday, January 15, 12
  • 26. MEMORY MANAGEMENT assign / weak retain / strong message to nil delegate delegate is legal retain autorelease nil 3 2 View2 View3 nil View3 nil nil re ta in if ([_delegate respondsToSelector: 2 @selector(requiredMethod)]) { View4 [_delegate requiredMethod]; } View2 nil Sunday, January 15, 12
  • 27. MEMORY MANAGEMENT Kill View4? retain / strong delegate -1 -1 retain 1 2 2 View4 View2 View3 nil View3 nil nil -1 -1 -1 dealloc release removeFrom Superview Sunday, January 15, 12
  • 28. RETAIN CYCLE LEAK!?! retain delegate retain 2 2 View2 View3 View3 nil nil Няма останали *указатели към обектите Sunday, January 15, 12
  • 29. MEMORY MANAGEMENT Kill View4? retain / strong [subviews <#cleanUpDelegates#>] delegate -1 retain 2 3 2 View4 View2 View3 View2 nil View3 nil nil -1 -1 -1 dealloc release removeFrom Superview Sunday, January 15, 12
  • 30. MEMORY MANAGEMENT Kill View4? -1 -1 -1 1 1 1 View4 View2 View3 nil nil nil -1 -1 -1 They will be autoreleased or released in dealloc dealloc release removeFrom of the owner Superview Sunday, January 15, 12
  • 31. MEMORY MANAGEMENT autorelease 0 0 0 View4 View2 View3 nil nil nil Sunday, January 15, 12
  • 32. ПРИМЕРИ if ([defaults objectForKey:@"actorsPlayed"] != nil) { ! ! [_actorsPlayed release]; ! ! _actorsPlayed = nil; ! ! _actorsPlayed = [[defaults objectForKey:@"actorsPlayed"] retain]; ! } NSDictionary *currRecord = [[NSDictionary alloc] ! ! ! ! ! ! ! ! initWithObjects:[NSArray arrayWithObjects: [NSNumber numberWithInt:highScore], _game.playerName, nil] ! ! ! ! ! ! ! ! forKeys:[NSArray arrayWithObjects:@"score", @"name", Array autorelease nil]]; NSMutableArray *diffHighScore = [[NSMutableArray alloc] initWithArray:[_localHiscores objectForKey:key]]; Sunday, January 15, 12
  • 33. NAVIGATION CONTROLLER Основи Sunday, January 15, 12
  • 34. NAVIGATION CONTROLLER CHAPTER 3 Navigation Controllers Figure 3-3 The navigation stack UINavigationController Navigation stack viewControllers (NSArray) View controller topViewController visibleViewController Your main responsibility is to push new view controllers onto the stack in response to user actions. Each v controller you push on the navigation stack is responsible for presenting some portion of your applicat Sunday, January 15, 12 data. Typically, when the user selects an item in the currently visible view, you create a new view contro
  • 35. NAVIGATION CONTROLLER NSArray of ViewControllers Root VC VC2 VC3 Visible Top 0 1 2 3 3 • popToRootViewControllerAnimated:<#(BOOL)#> • popToViewController:<#(UIViewController *)#> animated:<#(BOOL)#> • popViewControllerAnimated:<#(BOOL)#> • pushViewController:<#(UIViewController *)#> animated:<#(BOOL)#> Sunday, January 15, 12