2

Automatic indentation in my Xcode sometimes comes out wrong. I can't see any rhyme or reason to when it is correct and when it isn't. Here is a typical case where Xcode got it wrong. Selecting and asking Xcode to re-indent does not help. Of course I can fix it manually. But it would be much better to fix whatever is wrong with my Xcode.

Any successful experiences out there?

-(UIFont*) font {
    UIFont* actual = self.actualFont;
    if (actual) {
        return actual;
    }
WJStyleSheet* sheet = self.styleSheet;
UIFont* r = sheet.font;
return r;
}
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
  • Pasting that code into XCode 4.3 indented fine here. Messing with the indentation manually and then selecting the code + pressing Control-I reformatted it correctly. So.... no idea. – spring Jul 17 '12 at 01:36
  • I'm having this same problem with 4.5.2, but it doesn't happen all the time. It is infrequent and hard to reproduce on command, but annoying. – MikeS Jan 18 '13 at 15:41
  • This is so annoying, happens to me two to three times a week with XCode 4.6.2 (am working with C++ classes mixed in with Objective-C). Usually starts happening after I close an if statement's code block. Then everything after that if statement is broken. Naturally, it only happens now and then though! – John Wordsworth May 21 '13 at 00:45
  • Do you have syntax errors (IE, closing braces with no open or opens with no close?) before or after this? I find the auto indent can get funked up if braces are mismatched. – ArtOfWarfare Jan 27 '14 at 04:59

1 Answers1

0

Does code completion still work completely. Can you for example type self.actual and then hit CTRL + SPACE and get a coloured code completion suggestion with the class next to actualFont? If not then I think this is related to the code completion which can get corrupted in Xcode.

I could fix this using the following answer: https://stackoverflow.com/a/8165886/784318

Community
  • 1
  • 1
Besi
  • 22,579
  • 24
  • 131
  • 223