Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Strange behaviour in NSMutableArray.

I've created object and filled it.

NSMutableArray *array = [[NSMutableArray alloc] 
                         initWithObjects:@"1",@"2",@"3",@"4", nil];
[array removeObjectAtIndex:0];

Before removing it looks like:

array   NSMutableArray *    0x1040b5e0
[0] id  0x00088a44 @"1"
[1] id  0x00088a54 @"2"
[2] id  0x00088a64 @"3"
[3] id  0x00088a74 @"4"

After removing FIRST element:

array   NSMutableArray *    0x1040b5e0
[0] id  0x00000000 
[1] id  0x00088a54 @"2"
[2] id  0x00088a64 @"3"

What am i doing wrong here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

Are you using lldb for debugging? Try gdb if so.

lldb has known bugs of this nature where it reports the incorrect values of variables during a debug session.

To change the debugger to gdb:

  1. Click your target in the toolbar
  2. Select 'edit schemes'
  3. Make sure the 'run' scheme is selected in the pane on the left.
  4. Change the 'Debugger' dropdown from lldb to gdb.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...