Code completion for multi-parameter method names in Xcode 4 - xcode

In Xcode4, I'm finding that I can't get code completion to readily narrow for multi-parameter method names where the first part is common. For example, consider the following methods from UITableViewDelegate:
- tableView:viewForHeaderInSection:
- tableView:heightForHeaderInSection:
- tableView:accessoryTypeForRowWithIndexPath:
...
The list goes on; there are quite a few methods that start tableView. If I type "tableView", the list is long and not quickly navigated. If I type "tableView:", code completion is exited as soon as I type the colon (:). If I type a run-on such as "tableViewview", completion also exits, presumably as it no longer literally matches the first method name part.
Is there some way to complete via the keyboard on such a list without resorting to either mousing around or clattering out a random number of arrow key hits to navigate the long list? I'm having a hard time believing that code completion for multi-parameter Objective-C methods is so limited, but neither experimentation nor documentation have proved illuminating thus far.
Update for clarification:
Above I'm referring to completion of a method declaration (e.g. in a .m file), not of a method call. For method calls, Xcode 4.x does completion for each method parameter part independently; this works great. The problem above only applys to declarations, generally when starting to write a new method implementation in a .m file.

It does seems that the behavior you expect is (unfortunately) not implemented in Xcode. However, I've found a partial solution: code completion works when you specify the complete first part of the multi-parameter method, i.e. if you type this (with space at the end)
- tableView:(UITableView *)tableView
and press ESCAPE key then the code completion dialog will appear and you will be able to keep typing the rest of the method name.
You are probably wondering:
"Oh boy, do I really have to type in this long preamble just to get
my code completion?"
Code snippets to the rescue! You just have to type the preamble once and convert it into snippet. I found it's best to configure it the following way, don't forget to add space at the end of code part, it will make things easier.
How should you use the thing you've just created? In your .m file start typing tabl and Xcode will let you autocomplete the snippet for you. Once the preamble is placed press ESC to reveal the auto-completion list.
This solution is not very robust, since you have to create a snippet for every multi-part method you want to use, but it does save some time and there aren't that many multi-part method names that share the same prefix.

I'm annoyed by this problem for quite a long time. Now I can verify that there is no way to do even in the newest Xcode 5, I submitted a bug report:
Multi-parameter method declaration completion in Xcode
Please dup it if you also want it.

Oh sorry, it does not work that way I mentioned with protocol stubs like you wanted in your update.
I use Accessorizer for that, an app in the mac app store to fully implement the declaration of your delegate/protocol methods you want to implement. Hope that help a little bit.
Old post:
I use Tab ⇥ for this.
Example I often have:
You want one of many init methods in the code completion.
Then you don't want to scroll down or use to many keystrokes to get to the right method.
Hit i > hit Tab ⇥ > init is completed.
Hit Escape ⎋ and then w and then again Tab ⇥ for all these initWith methods.
You can even use Tab ⇥ / Escape ⎋ after the first parameter, when there is more than the method with only one parameter.
In your case hit t > Tab ⇥ > Escape ⎋ > a and Return ↩, there you got your third method.
You can also jump to the previous code completion argument with Shift ⇧ + Tab ⇥.

Related

How to display a value to the homescreen during a ti-89 titanium program

In relationship to this thread, this is also what i am kind of trying to do but i have had a bit more leeway in this.
My problem is i am currently working on a defining program (for my ti-89 titanium) to write out the definitions of variables. However, considering i had indefinite amounts of variables to add, i thought using the define function over and over again would waste memory and processing power. So my thinking was Save the variable to another variable to be defined in a later portion of the program.
prompt x
lbl x_d_r
x_d_r->q:Goto def
lbl def
define expr(q)[1]=x
where x_d_r has no assigned value. So the program was supposed to use the defined string as a list value to be x. However the obvious error came about.
So i played around on the home screen and program screen for a bit and came across entry(1) and ans(1). See back on the ti-83 (or 84) i could basically go (If i remember correctly)
disp q*1
x->ans(1)
However ans(1) on a ti-89 titanium is based upon the last answer submitted to the homescreen. Even then, ans(1) or entry(1) gets replaced in the program by just that. Lucky me, i found a way to avoid this.
Prgm
expr(char(120)&char(22)&char(97)&char(110)&char(115)&char(40)&char(49)&char(41))
EndPrgm
For those that do not know, this is simply expressing x->ans(1) which is a way for the code to transmit ans(1) within a program without removing the code to say so.
But it still does not work as a value needs to be sent to the home screen in order for it to record properly. This is one of those advantages that the ti-84 or ti-83 i wish it still had on the titanium. So i have spent some time searching for ways how i can display values of q to the home screen from within a program.
So far i learned that functions when used straight from the home screen return the value of q to the same place. However i have no way of implementing this in an actual program as the function does not wish to transmit the value to the home screen, and its rather useless within the program.
Secondly i have found this website which details methods of such ways to return values to the homescreen. While method 1 seems to hold promise, i do not seem to have any way of accessing that folder/program. Most likely because it is one that he made and has not shared its location on the pdf. I do like the expr("q"&":stop"), but q is not evaluated out so maybe i would have to rework it somehow.
While this was happening, i thought some other ideas could be using the paste key within a program but i have no idea how to implement stuff found from getkey let alone how the second and grab buttons factor in.
Or i could somehow have the ans(1) look to someplace else other than the home screen. Preferably to the i/0 screen but maybe to some other list or data matrix.
Anybody have any ideas on how to relay a value to the homescreen be it through function, pasting or something, and have the program i defined earlier define it as a value?
UPDATE+1
Ok i am beginning to question if maybe i am making it more complex than it needs to be...
After all, i am only going for just x->x_d_r[1], which is already defined elsewhere. So does it beat x->q:Goto def
Lbl def
Define expr(q)=x
(Or something like that which calls to a history recording program to define values?)
in terms of processing speed and memory count?
Got it. See here for what i was really trying to do.
So as an explanation of what the main problem was again, i wanted to be able to post a string value of q to be defined by another value of x.
The expr( function is quite a powerful tool on the ti-89 and like the person in that other forum, underestimated it. See what the person was trying to do was
InputStr "Function:",f(x)
expr(f)→f(x)
And was later answered by reworking it as
InputStr "function", n
expr(n & "->f(x)")
The expression tool just simply expresses what is in the parentheses. So during break periods in school today, i reworked in my head thinking "What if i tried rewriting the parenthesis out so it reads Expr("x->"&String(q))?
Lo-and-behold it works. Tested it with the fuller version of define to get
td()
Prgm
Prompt X
x_d_r->q
expr("x->"&string(q)&"[1]")
Disp x_d_r[1]
Delvar x_d_r
EndPrgm
Tried, tested and true. Works all the way. See what i think is happening is that anything that is not within the quotes is evaluated immediately in an expression while the the quoted objects are simply expressed and added later in response to the "&" key. Furthermore it makes sense if i was to describe it more with english; "Express x to be stored into the string of q's respective table".
While for variables sake i would have to look into ways to make x_d_r local only to the program without compensating the fact that the x_d_r portion is not considered a store value when executing x_d_r->q. But knowing what i know now i could probably do
expr("q"+"x_d_r"&->a)
expr("x->"&string(a)-"q"&"[1]")
In order to bypass that problem.

Can someone show a known good working function in Xojo 2014?

So.. I just downloaded Xojo 2014 for OS X, and up to this point have found it a pretty simple and effective development environment.
However, I've been trying to make a function or sub routine for 45 minutes. Every time I try following tutorials or the Xojo documentation I get the following error:
I've followed (even though I could be missing something) the directions here: http://docs.xojo.com/index.php/Function
Even though there is no full example in the documentation (bad development environment).
Also, in the screen shot is showing a sample function I copied and pasted off Xojo forums and is supposed to work. I'm not a programming newb per say, but more an Xojo newb. I've also had experiences with silly bugs in RealStudio in the past.
Can someone maybe point out what I could be missing?
You cannot use the Function, Sub, End Function, or End Sub lines in the method editor. Doing so will cause a syntax error because method declarations are automatically added by the IDE based on the values you enter into the method editor's name, parameters, and return type fields.
e.g.
as said,
Function, Sub, End Function, or End Sub is done for you,
you can do 'exit sub' if nothing need to be returned, else just return a proper value
like some events need a true or false, so if you need the exit the function, just return false
You cannot add inline functions within your Xojo code. You add methods to your project items these ways:
Insert->Method
"+" button on editor toolbar, then Method
Insert button on main toolbar, then Method
Option-Command-M (on OS X)

Partial completions in Xcode?

Is it possible to have partial completions in Xcode? By that I mean if we were calling a method on a string
eg.
[string <some method here method>]
on XCode, currently if you type
[string
and hit escape, you'll see suggestions for methods you can call on the object. If I wanted to find the method which checks equality isEqualToString, I only get the suggestion if I start typing isE..., but is there a way code completion will still give isEqualToString as a suggestion if I type "equal" ie. it matches against any part of a method?
Thanks!
I'm sorry but there is no way, there aren't really any ways to change the way Xcode handles the code completion, all you can do is turn it on or off. Your best bet may be a feature request to Apple.

Matlab GUI changes 2009a->2011b?

I have a skeleton GUI application which puts up a simple set of menus whose entries share a common callback function whose only effect is to set the value of a global variable, MenuItem, which is different for each entry. Different functions are then called for each value of MenuItem inside a Switch-Case expression, the Switch-Case is held inside a While loop whose exit condition is for MenuItem to attain a certain value. In the tail of the While loop is a uiwait call, after the Switch-Case.
This worked fine under Matlab 2009a but since I upgraded to Matlab 2011b it is broken.
Under Matlab 2011b the value of MenuItem is changed in the callback but this changed value does not seem to propagate into the Switch-Case.
Any ideas of changes between 2009a and 2011b which might have caused this, and workarounds for them? I tried reading the release notes but couldn't spot anything which appeared relevant.
(I appreciate this is a slightly unorthodox way of structuring a GUI, it is born out of a background in commandline programming)
I don't think the GUI API has changed in MATLAB between 2009a and 2011b. If the MenuItem changes do not propagate into the switch cases, then you should check that the case statements that you compare against are still valid. You should at least post your code around the switch statement in order to make a more reasonable diagnosis.

Stop Visual Basic 6 from changing my casing

Very simple question that is apparently impossible to find a decent answer to: How can I make Visual Basic 6 stop changing my ^##*ing variable casing!?!
I know that the general opinion of a great many VB users is that this "feature" is actually quite helpful, but I doubt that they use it much with any source control system. This is absolutely INFURIATING when you are trying to collaborate on a project of any significant size with several other developers. If ignored, you produce thousands of false-positive "changes" to your files (even ones with no actual code changes!) that pollute the revision history and make it near impossible in some cases to locate the actual change that took place.
If you don't ignore it (like my office, where we have been forced to implement a "no unneeded case change" policy), you spend 5x the time you would normally on each commit because you have to carefully revert out VB's "corrections" on every file, sometimes reverting hundreds of lines to put in a one line change.
Surely there must be a setting, plugin, hack, etc. out there that can remove this unwanted "feature"? I am willing to take any method I can get as long as it doesn't require me to pick through piles of phantom diffs. And to squash a couple of complaints up front: No, I can't turn off case detection in my diff tool, that's not the point. No, we can't just make the case changes globally. We're working with hundreds of thousands of LOC being worked on by multiple developers spanning many years of development. Synchronizing that is not feasible from a business standpoint. And, finally: No, we cannot upgrade to VB.net or port to another language (as much as I would love to).
(And yes, I am just a tiny bit peeved at the moment. Can you tell? My apologies, but this is costing me time and my company money, and I don't find that acceptable.)
Depending on your situation adding
#If False Then
Dim CorrectCase
#End If
might help.
Here is a real world scenario and how we solved it for our 350k LOC VB6 project.
We are using Janus Grid and at some point all the code lines which referenced DefaultValue property of JSColumn turned to defaultValue. This was an opportunity to debug the whole IDE nuisance.
What I found was that a reference to MSXML has just been added and now the IDE picks up ISchemaAttributes' defaultValue property before the Janus Grid typelib.
After some experiments I found out that the IDE collects "registered" identifiers in the following order:
Referenced Libraries/Projects from Project->References in the order they are listed
Controls from Project->Components (in unknown order)
Source Code
So the simple fix we did was to create a dummy class/interface with methods that hold our proper casing. Since we already had a project-wide typelib we referenced from every project before anything other typelib, this was painless to do.
Here is part of the IDL for our IUcsVbIntellisenseFix interface:
[
odl,
uuid(<<guid_here>>),
version(1.0),
dual,
nonextensible,
oleautomation
]
interface IUcsVbIntellisenseFix : IDispatch {
[id(1)] HRESULT DefaultValue();
[id(2)] HRESULT Selector();
[id(3)] HRESULT Standalone();
...
}
We added a lot of methods to IUcsVbIntellisenseFix, some of them named after enum items we used to misspell and whatever we wanted to fix. The same can be done with a simple VB class in a common library (ActiveX DLL) that's referenced from every project.
This way our source code at some point converged to proper casing because upon check-out the IDE actually fixed the casing as per IUcsVbIntellisenseFix casing. Now we can't misspell enums, methods or properties even if we try to.
SIMPLE WAY: Dim each variable in the case that you want. Otherwise, VBA will change it in a way that is not understandable.
Dim x, X1, X2, y, Yy as variant
in a subroutine will change ALL cases to those in the Dim statement
I can sympathise. Luckily we're allowed to turn off case sensitivity in our version control diff tool!
It seems the VB6 IDE automatic case-correction occasionally changes case in variable declarations and references, perhaps depending on the order in which modules are listed in the VBP file? But the IDE doesn't tell you that the file needs to be saved. So the problem only shows up when you saved the file because of another edit. We briefly tried to prevent this by checking out all the files in a project and setting the case carefully, but it didn't go away.
I suppose you could list the variable names that are affected - the usual suspects are one letter names like "I", "X" and "Y", perhaps because they are used in standard event handlers like MouseDown. Then write an add-in that'll search for all declarations " As" and force the case to upper. Run the add-in on your modules before you check them in. You might be able to trigger the add-in to run automatically when you save in VB6.
EDIT: Something I've just thought of: adapt Fred's answer. From now on, every time you check in a file, add a block at the top to establish canonical case for the usual suspects. If nothing else, it's easier than reverting hundreds of lines by hand. Eventually you will have this block in every file & maybe then the problem will stop happening.
#If False Then
Dim I, X, Y ' etc '
#End If
I standardised the case across the codebase, normally by using the examples above (Dim CorrectCase), and removing it again.
I then triggered VB to save EVERY file, by doing a case sensitive search/replace of "End" with "End" (no functional change, but enough to get VB to resave).
Once that was done, I could then do a single commit to standardise the case, making it MUCH easier to keep on top of it at a later date.
In this example VB6 was changing the case of the following line following a typo I made when referencing a library: -
Dim MyRecordset As ADODB.REcordset
Ugly, and now every other instance of an ADODB.REcordset thus acquired the new misspelling. I fixed this as follows: -
Type in a new declaration as follows
Dim VB6CasingSucks AS ADODB, Recordset
Note the comma and space after ADODB. Hit [ENTER] for VB6 to check the line.
At this point all instances of REcordset change back to Recordset.
Delete your new declaration.
I don't know if this fix will help with enums/other variable names.
Specifically for controlling the case of enum values, there is a VB6 IDE add-in which may be helpful. Enums seem to have a slightly unique version of this problem.
As described in the link below:
The VB6 IDE has an annoying quirk when it comes to the case of Enum
members. Unlike with other identifiers, the IDE doesn't enforce the
case of an Enum member as it was declared in the Enum block. That
occasionally causes an Enum member that was manually written to lose
its original case, unless a coder typed it carefully enough.
...
However, if a project contains a lot of Enums and/or a particular Enum
has a lot of members, redeclaring the members in each of them can get
quite tedious fast. ...
Ref: http://www.vbforums.com/showthread.php?778109-VB6-modLockEnumCase-bas-Enforce-Case-of-Enums
...load and unload the add-in as needed via the Add-In Manager
dialog box. Usage is as simple as selecting the entire Enum block,
right-clicking and then choosing the "Lock Enum Case" context menu
item.
I have a similar problem:
in a bas module there I wrote :
Private sub bla_bla()
Dim K as integer
End Sub
so in a class module the Dim k as integer will automatically be replaced by IDE become 'Dim K as integer' <-- it's not logical but then:
I correct the bas module become:
Private sub bla_bla()
Dim k as integer
End Sub
then magically the problem in the class module was solved (still be k and not automatically replaced by IDE become K). Sorry I'm poor in English
I don't think there's any to do it. The IDE will change the case of the variable name to whatever it is when it's declared. But, honestly, back in the day I worked on several large VB6 projects and never found this to be a problem. Why are people on your development team constantly changing variable declarations? It seems like you have not established a clear variable naming policy that you enforce. I know your upset, so no offense, but it might be your policies that are lacking in this regard.
Unfortunately, according to this SO thread, alternate VB6 IDEs are hard to come by. So, your best bet is to solve this problem via policy. Or move to VB.NET. :)
Wow. I've spent a lot of time programming in VB6 and I have no idea what you're on about. The only thing I can think you're referring to is that intellisense will change the capitalization of variable names to match their declarations. If you're complaining about that, I would have to wonder why the hell they've been entered any other way to begin with. And if that is your problem, no, there's no way to disable it that I'm aware of. I'd suggest you, in one go, check out every file, make sure the caps on the declarations and uses of variables all match and check back in.

Resources