SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
ARC of a Developer Part.1




11   11   22
Automatic Referrence Counting

          • Objective-C


          •               -


          •                    - retain release


          •           - weak              weak referrence




11   11   22
•

          •

               • EXC_BAD_ACCESS



          •2       release

               • NSZombie



          •

          •



11   11   22
ARC

          • GC


          •


               • retain/release 2.5


               • autoreleasepool 6


               • objc_msgSend 33%




11   11   22
ARC

          •




11   11   22
ARC

          •           ARC


          • LLVM3.0




          •            -fobjc-arc




11   11   22
•    -fno-objc-arc




11   11   22
• iOS4      weak reference


               • __unsafe_unretained


          • weak reference




11   11   22
• __strong


          • __weak


          • __unsafe_unretained


          • __autoreleasing




          •




11   11   22
Before ARC

          •


          •    autorelease


          •




11   11   22
•


               • VB6


               • COM


               • Objective-C


               •


          • JAVA .NET          Obj-C   GC




11   11   22
• NSObject *obj = [[NSObject alloc]init];




                     * obj

                                                      NSObject

                                                         1


11   11   22
• NSObject *obj = [[NSObject alloc]init];


          • NSObject *obj2 = [obj retain];

                     * obj

                                                      NSObject

                                                         2
                    * obj2




11   11   22
• NSObject *obj = [[NSObject alloc]init];


          • NSObject *obj2 = [obj retain];


          • [obj release];

                                                      NSObject

                                                         1
                     * obj2




11   11   22
• NSObject *obj = [[NSObject alloc]init];


          • NSObject *obj2 = [obj retain];


          • [obj release];


          • [obj2 release];                           NSObject

                                                         0


11   11   22
Autorelease

          •

               +(id)array{
                   NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease];
                   return array;
               }




                        * array

                                                                NSArray

                                                                     1

11   11   22
Autorelease

          •

               +(id)array{
                   NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease];
                   return array;
               }




                        * array

                                                                NSArray

                       release                                       1
                 autorelease pool

11   11   22
Autorelease

          •

               +(id)array{
                   NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease];
                   return array;
               }




                                                                NSArray

                       release                                       1
                 autorelease pool

11   11   22
Autorelease

          •

               +(id)array{
                   NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease];
                   return array;
               }




                                                                NSArray

                                                                     0

11   11   22
Retain Release Autorerelease

          •


          •




11   11   22
11   11   22
•


               •




11   11   22
Xcode Static Analyzer

          • Xcode   Analyze


          •




11   11   22
ARC

          •


          •    Retain   Release




11   11   22
• __strong


          • __weak


          • __unsafe_unretained


          • __autoreleasing




11   11   22
nil

          •                     nil


               • id __strong obj1;


               • id __strong obj1 = nil;




11   11   22
__strong

          •


          • id


               • id test = [[NSObject alloc]init];


               • id __strong test = [[NSObject alloc]init];


          •      retain release


          •                          strong




11   11   22
__strong

          • dealloc   release


               •                           release


               •                          Retain


               •                Release




11   11   22
__strong

                                         +1                    +1
               {
                    NSMutableArray *array = [[NSMutableArray alloc]init];

                    [array   addObject:[[NSObject   alloc]init]];
                    [array   addObject:[[NSObject   alloc]init]];
                    [array   addObject:[[NSObject   alloc]init]];
                    [array   addObject:[[NSObject   alloc]init]];
               }

          • array                            +1


          •                    array                  -1




11   11   22
Retain
           {
                   NSMutableArray *array = [[NSMutableArray alloc]init];

                   [array   addObject:[[NSObject   alloc]init]];
                   [array   addObject:[[NSObject   alloc]init]];
                   [array   addObject:[[NSObject   alloc]init]];
                   [array   addObject:[[NSObject   alloc]init]];
           }

               @property (nonatomic,retain) NSMutableArray *array;

               {
                   self.array = [[[NSMutableArray alloc]init]autorelease];

                   [array   addObject:[[[NSObject   alloc]init]autorelease]];
                   [array   addObject:[[[NSObject   alloc]init]autorelease]];
                   [array   addObject:[[[NSObject   alloc]init]autorelease]];
                   [array   addObject:[[[NSObject   alloc]init]autorelease]];
               }


11   11   22
Autorelease

          • Relase



                                           +1                    +1
               {
                     NSMutableArray *array = [[NSMutableArray alloc]init];

                     [array   addObject:[[NSObject   alloc]init]];
                     [array   addObject:[[NSObject   alloc]init]];
                     [array   addObject:[[NSObject   alloc]init]];
                     [array   addObject:[[NSObject   alloc]init]];
               }




11   11   22
•       autorelease


          •                                                 autorelease pool




               +(id)array{
                   id obj = [[NSMutableArray alloc]init];
                   return obj;
               }




11   11   22
assign         __unsafe_unretained

                     copy               __strong

                    retain              __strong

                    strong              __strong

               unsafe_unretained   __unsafe_unretained

                     weak               __weak


11   11   22
strong

          •        release retain


               •




11   11   22
11   11   22
•




               A

                   B   C

                   E   D
11   11   22
A

                   B   C

                   E   D
11   11   22
A

                        B   C
               assign
                        E   D
11   11   22
@interface Test : NSObject{
                   id childObject;
               }
               -(void)setObject:(id)child;

               @end



               {
                   id test1 = [[Test alloc]init];
                   id test2 = [[Test alloc]init];

                   [test1 setObject:test2];
                   [test2 setObject:test1];
               }




11   11   22
{
               id test1 = [[Test alloc]init];
               id test2 = [[Test alloc]init];

               [test1 setObject:test2];
               [test2 setObject:test1];
     }




                        test1                   test2

                       test1                    test2
11   11   22
__weak

          • Retain

               @interface Test : NSObject{
                   id __weak childObject;
               }
               -(void)setObject:(id)child;

               @end




                      test1                  test2

11   11   22
__weak

          •            nil


          •




               test1   test2

11   11   22
__weak


                                         +1

                   id __weak obj = [[NSObject alloc]init];




          •                   delegate




11   11   22
autorelease pool

          •


          •              Thread
              NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];

              //

              [pool drain];


               @autoreleasepool {
                   //
               }


          • LLVM3.0           ARC

11   11   22
•




11   11   22
11   11   22

Más contenido relacionado

La actualidad más candente

Ow2 Utilities, OW2con'12, Paris
Ow2 Utilities, OW2con'12, ParisOw2 Utilities, OW2con'12, Paris
Ow2 Utilities, OW2con'12, Paris
OW2
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
Anton Arhipov
 
Locks (Concurrency)
Locks (Concurrency)Locks (Concurrency)
Locks (Concurrency)
Sri Prasanna
 
2013 gr8 conf_grails_code_from_the_trenches
2013 gr8 conf_grails_code_from_the_trenches2013 gr8 conf_grails_code_from_the_trenches
2013 gr8 conf_grails_code_from_the_trenches
Edwin van Nes
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
Agora Group
 

La actualidad más candente (20)

Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
The Ring programming language version 1.10 book - Part 104 of 212
The Ring programming language version 1.10 book - Part 104 of 212The Ring programming language version 1.10 book - Part 104 of 212
The Ring programming language version 1.10 book - Part 104 of 212
 
Ow2 Utilities, OW2con'12, Paris
Ow2 Utilities, OW2con'12, ParisOw2 Utilities, OW2con'12, Paris
Ow2 Utilities, OW2con'12, Paris
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
 
Snapshot Testing @ CocoaheadsNL
Snapshot Testing @ CocoaheadsNLSnapshot Testing @ CocoaheadsNL
Snapshot Testing @ CocoaheadsNL
 
JDK Power Tools
JDK Power ToolsJDK Power Tools
JDK Power Tools
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
Ow2 Utilities - The Swiss Army Knife Of Ow2 Projects
Ow2 Utilities - The Swiss Army Knife Of Ow2 ProjectsOw2 Utilities - The Swiss Army Knife Of Ow2 Projects
Ow2 Utilities - The Swiss Army Knife Of Ow2 Projects
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database Jones
 
Locks (Concurrency)
Locks (Concurrency)Locks (Concurrency)
Locks (Concurrency)
 
Lecture 3-ARC
Lecture 3-ARCLecture 3-ARC
Lecture 3-ARC
 
Testing (eng)
Testing (eng)Testing (eng)
Testing (eng)
 
Making Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVMMaking Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVM
 
2013 gr8 conf_grails_code_from_the_trenches
2013 gr8 conf_grails_code_from_the_trenches2013 gr8 conf_grails_code_from_the_trenches
2013 gr8 conf_grails_code_from_the_trenches
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
02 - Basics of Qt
02 - Basics of Qt02 - Basics of Qt
02 - Basics of Qt
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Execution model and other must-know's
Execution model and other must-know'sExecution model and other must-know's
Execution model and other must-know's
 

Destacado

WRECTACULAR 2011 exhibitor info
WRECTACULAR 2011 exhibitor infoWRECTACULAR 2011 exhibitor info
WRECTACULAR 2011 exhibitor info
jmorgan2077
 
Eng2 d tkm_intro
Eng2 d tkm_introEng2 d tkm_intro
Eng2 d tkm_intro
dcowley
 
Arc of developer part2
Arc of developer part2Arc of developer part2
Arc of developer part2
Junpei Wada
 

Destacado (18)

การสร้าง organization charts
การสร้าง organization chartsการสร้าง organization charts
การสร้าง organization charts
 
WRECTACULAR 2011 exhibitor info
WRECTACULAR 2011 exhibitor infoWRECTACULAR 2011 exhibitor info
WRECTACULAR 2011 exhibitor info
 
Tuesday
TuesdayTuesday
Tuesday
 
Eng2 d tkm_intro
Eng2 d tkm_introEng2 d tkm_intro
Eng2 d tkm_intro
 
Sample Selection of Styles
Sample Selection of StylesSample Selection of Styles
Sample Selection of Styles
 
僕の脳で何が起こったか
僕の脳で何が起こったか僕の脳で何が起こったか
僕の脳で何が起こったか
 
DfC_ny 18112010 design for conversion
DfC_ny 18112010 design for conversionDfC_ny 18112010 design for conversion
DfC_ny 18112010 design for conversion
 
Comic life
Comic lifeComic life
Comic life
 
เทคนิคการทำPs
เทคนิคการทำPsเทคนิคการทำPs
เทคนิคการทำPs
 
Working With Therapeutic Program Parents
Working With Therapeutic Program ParentsWorking With Therapeutic Program Parents
Working With Therapeutic Program Parents
 
การสร้างแผนผัง Organization Chat
การสร้างแผนผัง Organization Chatการสร้างแผนผัง Organization Chat
การสร้างแผนผัง Organization Chat
 
Arc of developer part2
Arc of developer part2Arc of developer part2
Arc of developer part2
 
Apple Inc
Apple IncApple Inc
Apple Inc
 
Programação para dispositivos móveis com PhoneGap Cordova
Programação para dispositivos móveis com PhoneGap CordovaProgramação para dispositivos móveis com PhoneGap Cordova
Programação para dispositivos móveis com PhoneGap Cordova
 
Antimalarial drug efficacy and drug resistance(yemen)
Antimalarial drug efficacy and drug resistance(yemen)Antimalarial drug efficacy and drug resistance(yemen)
Antimalarial drug efficacy and drug resistance(yemen)
 
Logica de programação / Algoritmos em Portugol
Logica de programação / Algoritmos em PortugolLogica de programação / Algoritmos em Portugol
Logica de programação / Algoritmos em Portugol
 
Burkholderia spp.
Burkholderia spp.Burkholderia spp.
Burkholderia spp.
 
Styles
StylesStyles
Styles
 

Similar a Arc of developer part1

Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
S Akai
 
ARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマーARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマー
Satoshi Asano
 
Automatic Reference Counting
Automatic Reference Counting Automatic Reference Counting
Automatic Reference Counting
pragmamark
 
Easy undo.key
Easy undo.keyEasy undo.key
Easy undo.key
zachwaugh
 

Similar a Arc of developer part1 (11)

Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
 
ARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマーARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマー
 
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
 
iOS Memory Management Basics
iOS Memory Management BasicsiOS Memory Management Basics
iOS Memory Management Basics
 
Automatic Reference Counting
Automatic Reference CountingAutomatic Reference Counting
Automatic Reference Counting
 
Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
 
Automatic Reference Counting
Automatic Reference CountingAutomatic Reference Counting
Automatic Reference Counting
 
Automatic Reference Counting
Automatic Reference Counting Automatic Reference Counting
Automatic Reference Counting
 
Easy undo.key
Easy undo.keyEasy undo.key
Easy undo.key
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

Arc of developer part1

  • 1. ARC of a Developer Part.1 11 11 22
  • 2. Automatic Referrence Counting • Objective-C • - • - retain release • - weak weak referrence 11 11 22
  • 3. • • EXC_BAD_ACCESS •2 release • NSZombie • • 11 11 22
  • 4. ARC • GC • • retain/release 2.5 • autoreleasepool 6 • objc_msgSend 33% 11 11 22
  • 5. ARC • 11 11 22
  • 6. ARC • ARC • LLVM3.0 • -fobjc-arc 11 11 22
  • 7. -fno-objc-arc 11 11 22
  • 8. • iOS4 weak reference • __unsafe_unretained • weak reference 11 11 22
  • 9. • __strong • __weak • __unsafe_unretained • __autoreleasing • 11 11 22
  • 10. Before ARC • • autorelease • 11 11 22
  • 11. • VB6 • COM • Objective-C • • JAVA .NET Obj-C GC 11 11 22
  • 12. • NSObject *obj = [[NSObject alloc]init]; * obj NSObject 1 11 11 22
  • 13. • NSObject *obj = [[NSObject alloc]init]; • NSObject *obj2 = [obj retain]; * obj NSObject 2 * obj2 11 11 22
  • 14. • NSObject *obj = [[NSObject alloc]init]; • NSObject *obj2 = [obj retain]; • [obj release]; NSObject 1 * obj2 11 11 22
  • 15. • NSObject *obj = [[NSObject alloc]init]; • NSObject *obj2 = [obj retain]; • [obj release]; • [obj2 release]; NSObject 0 11 11 22
  • 16. Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } * array NSArray 1 11 11 22
  • 17. Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } * array NSArray release 1 autorelease pool 11 11 22
  • 18. Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } NSArray release 1 autorelease pool 11 11 22
  • 19. Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } NSArray 0 11 11 22
  • 20. Retain Release Autorerelease • • 11 11 22
  • 21. 11 11 22
  • 22. • 11 11 22
  • 23. Xcode Static Analyzer • Xcode Analyze • 11 11 22
  • 24. ARC • • Retain Release 11 11 22
  • 25. • __strong • __weak • __unsafe_unretained • __autoreleasing 11 11 22
  • 26. nil • nil • id __strong obj1; • id __strong obj1 = nil; 11 11 22
  • 27. __strong • • id • id test = [[NSObject alloc]init]; • id __strong test = [[NSObject alloc]init]; • retain release • strong 11 11 22
  • 28. __strong • dealloc release • release • Retain • Release 11 11 22
  • 29. __strong +1 +1 { NSMutableArray *array = [[NSMutableArray alloc]init]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; } • array +1 • array -1 11 11 22
  • 30. Retain { NSMutableArray *array = [[NSMutableArray alloc]init]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; } @property (nonatomic,retain) NSMutableArray *array; { self.array = [[[NSMutableArray alloc]init]autorelease]; [array addObject:[[[NSObject alloc]init]autorelease]]; [array addObject:[[[NSObject alloc]init]autorelease]]; [array addObject:[[[NSObject alloc]init]autorelease]]; [array addObject:[[[NSObject alloc]init]autorelease]]; } 11 11 22
  • 31. Autorelease • Relase +1 +1 { NSMutableArray *array = [[NSMutableArray alloc]init]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; } 11 11 22
  • 32. autorelease • autorelease pool +(id)array{ id obj = [[NSMutableArray alloc]init]; return obj; } 11 11 22
  • 33. assign __unsafe_unretained copy __strong retain __strong strong __strong unsafe_unretained __unsafe_unretained weak __weak 11 11 22
  • 34. strong • release retain • 11 11 22
  • 35. 11 11 22
  • 36. A B C E D 11 11 22
  • 37. A B C E D 11 11 22
  • 38. A B C assign E D 11 11 22
  • 39. @interface Test : NSObject{ id childObject; } -(void)setObject:(id)child; @end { id test1 = [[Test alloc]init]; id test2 = [[Test alloc]init]; [test1 setObject:test2]; [test2 setObject:test1]; } 11 11 22
  • 40. { id test1 = [[Test alloc]init]; id test2 = [[Test alloc]init]; [test1 setObject:test2]; [test2 setObject:test1]; } test1 test2 test1 test2 11 11 22
  • 41. __weak • Retain @interface Test : NSObject{ id __weak childObject; } -(void)setObject:(id)child; @end test1 test2 11 11 22
  • 42. __weak • nil • test1 test2 11 11 22
  • 43. __weak +1 id __weak obj = [[NSObject alloc]init]; • delegate 11 11 22
  • 44. autorelease pool • • Thread NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; // [pool drain]; @autoreleasepool { // } • LLVM3.0 ARC 11 11 22
  • 45. • 11 11 22
  • 46. 11 11 22