An enumeration array containing a dictionary gives unexpected output

My question is why it displays the last 4 lines in the log (see below) ... are these objects part of the dictionary printed earlier in the log and should not be located at the end of the array? I am missing something fundamental here ... thanks

NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSURL URLWithString: @"www.stanford.edu"], 
    @"Stanford University", 
    [NSURL URLWithString: @"www.apple.com"], 
    @"Apple shop", 
    [NSURL URLWithString: @"cs193p.stanford.edu"], 
    @"CS193P course", 
    [NSURL URLWithString: @"itunes.stanford.edu"], 
    @"Stanford on iTunes U", 
    [NSURL URLWithString: @"stanfordshop.com"], 
    @"Stanford Mall", 
    nil];

NSMutableArray *myArray = [NSMutableArray arrayWithObjects:
    [NSString init],
    [NSURL URLWithString: @"www.stanford.edu"],
    [NSProcessInfo processInfo],
    dictionary,
    [@"Mutable string example" mutableCopy],
    [@"another mutable string" mutableCopy]];

NSEnumerator *enumerator = [myArray objectEnumerator];
id object;

while ((object = [enumerator nextObject])) {
    NSLog([object description]);
}

2009-07-02 09: 35: 12.756 WhatATool [6407: 10b] NSString
2009-07-02 09: 35: 12.756 WhatATool [6407: 10b] www.stanford.edu
2009-07-02 09: 35: 12.757 WhatATool [6407: 10b] <NSProcessInfo: 0x107e20 >
2009-07-02 09: 35: 12.758 WhatATool [6407: 10b] {
   " Apple" = www.apple.com;
   " CS193P" = cs193p.stanford.edu;
   "Stanford Mall" = stanfordshop.com;
   " " = www.stanford.edu;
   " iTunes U" = itunes.stanford.edu;
}
2009-07-02 09: 35: 12.758 WhatATool [6407: 10b]
2009-07-02 09: 35: 12.759 WhatATool [6407: 10b]
2009-07-02 09: 35: 12.760 WhatATool [6407: 10b] itunes.stanford.edu
2009-07-02 09: 35: 12.760 WhatATool [6407: 10b] Stanford on iTunes U
2009-07-02 09: 35: 12.761 WhatATool [6407: 10b] stanfordshop.com
2009-07-02 09: 35: 12.762 WhatATool [6407: 10b] Stanford Mall

+3
2

, , , NSMutableArray, .

NSMutableArray *myArray = [NSMutableArray arrayWithObjects:
    [NSString init],
    [NSURL URLWithString: @"www.stanford.edu"],
    [NSProcessInfo processInfo],
    dictionary,
    [@"Mutable string example" mutableCopy],
    [@"another mutable string" mutableCopy],
    nil];

?

+24

( "-Wall" ), :

:

NSMutableArray arrayWithObjects, .

+4

Source: https://habr.com/ru/post/1711705/


All Articles