Indenting Objective-C literals with Xcode
Asked Answered
G

2

16

Xcode think that this:

NSArray *persons = @[
    @{
        @"name": @"Bob",
        @"pet": @"cat"
    },
    @{
        @"name": @"Alice",
        @"pet": @"dog"
    }
];

would be better indented like so:

NSArray *persons = @[
@{
@"name": @"Bob",
@"pet": @"cat"
},
@{
@"name": @"Alice",
@"pet": @"dog"
}
];

Can you teach Xcode about indenting Objective-C literals?

Is there another alternative?

Note: I already know I can "force" indent with cmdopt], however this will go away when copying/pasting and will not fix the problem.

Gottfried answered 14/9, 2012 at 22:50 Comment(2)
All formatting goes away when copying/pasting unless you "paste with style", doesn't it?Ectomere
@Ectomere Yes, except it's called Paste and Preserve Formatting and the keyboard shortcut is opt+shift+cmd+VGottfried
L
5

Open a bug with http://bugreport.apple.com.

If you also submit it to OpenRadar, people outside Apple can read it. I can point you at this bug report about your specific issue: http://openradar.appspot.com/12394453

The more people who report this problem, the more priority Apple will give it.

Loadstone answered 31/10, 2012 at 1:44 Comment(1)
Just copy-and-pasted a new bug report against Xcode 4.6. sighHeartfelt
I
0

Xcode 5 auto-indents like this:

NSArray *persons = @[
                     @{
                         @"name": @"Bob",
                         @"pet": @"cat"
                         },
                     @{
                         @"name": @"Alice",
                         @"pet": @"dog"
                         }
                     ];
Individually answered 18/9, 2013 at 20:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.