Xcode autocomplete

Discussion in 'Mac Programming' started by RoyG, Nov 17, 2013.

  1. RoyG, Nov 17, 2013
    Last edited: Nov 17, 2013

    RoyG macrumors newbie

    Jul 24, 2011
    This is what I get:


    A BOUNDless expansion of the NSRect bounds.

    This is what I Expect:


    To access the NSRect values 'origin' and 'size'.

    So what is going on here? A bug in Xcode, or me being plain stupid?

    In the boundless expansion of 'bounds', there is no 'origin' or 'size' to spot.
  2. ArtOfWarfare macrumors G3


    Nov 26, 2007
    It looks like you're using the identifier bounds multiple times in that scope to refer to different things... That may be confusing Xcode's autocomplete.
  3. RoyG thread starter macrumors newbie

    Jul 24, 2011
    Oh no, that is not what happens. I have declared 'NSRect bounds' only once in the whole project, and that is within the scope you are seeing in that picture.

    It seems actually to be a bug in Xcode. It seems Xcode gets confused when I skipped one of the placeholders to fill in values for a method. I filled in dummy values for those fields, and then I got the result I expected.

    Under no circumstances should bounds refer to itself in this way, I could type 'bounds.bounds.bounds.bounds.bounds...' ad infinitum, and Xcode would not suggest anything else for me.
  4. gnasher729 macrumors P6


    Nov 25, 2005
    Can you hear me play the world's saddest song on the world's smallest violin? :D
  5. ArtOfWarfare macrumors G3


    Nov 26, 2007
    Huh - file a bug at bugreporter.apple.com
  6. iSee macrumors 68040


    Oct 25, 2004
    I've seen xcode's autocomplete get confused by syntax errors, especially ones immediately prior to were you are typing, as is the case here. I'm not quite sure I'd call it a bug, though. Autocomplete could handle this case better, so it's a good feature request.
  7. chown33 macrumors 604

    Aug 9, 2009
    Try changing the local variable name to something that's not a method or property, like 'bob'.

    If this solves the problem, then submit both your fail-case (bounds) and success-case (bob) in a bug-report to Apple. And be sure to tell them exactly which Xcode version it happens in.
  8. ArtOfWarfare macrumors G3


    Nov 26, 2007
    It's also the name of a method and property of self within the current scope. I'm not saying the autocomplete is valid, just pointing out where the confusion may lie.
  9. iMacFarlane macrumors 65816


    Apr 5, 2012
    Adrift in a sea of possibilities
    So, don't skip the placeholders then? Autocomplete is a godsend, but not infallible. Skipping the placeholders obviously breaks the autocomplete's parser logic, so ixnay on the ipskay.
  10. RoyG thread starter macrumors newbie

    Jul 24, 2011
    At first I was going to contest what you were saying there, but I decided to have another look, and you are right! It really slipped my mind. You are absolutely right.

    That does indeed tell a bit about how autocomplete works, because it should tell me about 'origin' and 'location' too, but those are completely gone until I fill in a dummy value for the placeholder value immediately before the value that is the problem.

    I have noticed before that autocomplete likes that you fill in values in order, so maybe I better make that habit.


    Yes, skipping placeholders is definitely something that autocomplete doesn't like, and the only solution is to do as you say. :)

Share This Page