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

    Joined:
    Jul 24, 2011
    #1
    This is what I get:

    [​IMG]

    A BOUNDless expansion of the NSRect bounds.

    This is what I Expect:

    [​IMG]

    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 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    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

    Joined:
    Jul 24, 2011
    #3
    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

    gnasher729

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

    ArtOfWarfare

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

    iSee

    Joined:
    Oct 25, 2004
    #6
    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

    Joined:
    Aug 9, 2009
    #7
    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 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #8
    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

    iMacFarlane

    Joined:
    Apr 5, 2012
    Location:
    Adrift in a sea of possibilities
    #9
    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

    Joined:
    Jul 24, 2011
    #10
    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