Xcode turn off code completion for NSObject - xcode

Is there a way to modify Xcode's (6.4/7.x beta whatever) code completion in such a way that neither the methods nor the properties of NSObject in a subclass of it are shown? I think, I don't use them frequently and it is pretty annoying when searching for another function whose name I can only slightly guess and then have to scroll through all the unnessecary suggestions coming from NSObject.
Thanks for your help

Not sure that its possible to adjust autocomplete only for NSObject and descendants (of course it might be the way), but there is another nice tool I'm using:
https://github.com/FuzzyAutocomplete/FuzzyAutocompletePlugin
It won't solve a problem of unnecessary suggestions you see, but
it's easier to add and remove from Xcode (comparing to manually internal Xcode files edit)
it solves a problem of "searching for another function whose name
I can only slightly guess"

Related

Xcode: Method definition not found message on a non-existing method (?) + slight color change in XIB

I have two basic practical problems:
1) The first one is really stupid. I receive a message saying: "Method definition for 'aIncreasedSelection' not found, together with an "Incomplete Implementation".
Well, that is quite strange, because I don't have this method in neither my .m or .h file (and the class name is mentioned in the remark).
I used to implement this method, but I deleted it because it was redundant. In a certain way, it appears as if my Xcode project can't let go of the method...
2) The second question is also a very mysterious one. I have a couple of viewControllers in which I have put the identical same background, and the identical same buttons. It's really identical in size and position in the screen as well (I defined the pixels). For an unknown reason, when I switch between the views, one of the buttons changes very slightly its color (it is a Photoshop created button with mirror effect on the bottom, it's the mirror that becomes lighter). That is really annoying because it's supposed to be identical; when the user switches views now, he can see that there is a color difference in the button (supposed to be planted as a button in a dock, which should be identical over the entire app)...
Very frustrating as I cannot solve these small mistakes... Any ideas? Thanks!
Regarding your first problem, if you have verified that it no longer exists in your .h or .m file, try to cmd+shift+k and clean your project, then rebuild. This should update everything and in theory solve that issue for you.
As for the second problem, it sounds strange indeed. Is there any chance you could provide pictures somehow? Are you statically loading the image into similar buttons, or are you doing something differently?
Re - opening my project solved my first problem (unlike the refresh - cmd + shift + k, which didn't work). The color problem is not solved despite :-/
It was definitely a bug since I didn't change anything. It is in fact - very confusing!

Multi-line NSTextFields

I want to know how to do something like Adium does, where when you type more text than the field can handle it expands into a new line. Like this:
Either how can I do this, or where in the Adium source code can I find this?
The view in Adium is AIMessageEntryTextView, plus its superclasses AISendingTextView and AITextViewWithPlaceholder, and the actual resizing (as opposed to figuring out the right size as a hypothetical ideal) is done by AIMessageViewController in response to AIViewDesiredSizeDidChangeNotification.
Do note that Adium is licensed under GPLv2, so unless you intend to use the same license when releasing your own project, you can't lift any of Adium's code for this purpose.
I am not exactly sure what Adium itself does there.
But I am pretty sure that you could just use NSTextView.
You can find it at the Apple Developer website.
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextView_Class/Reference/Reference.html
Furthermore this Tech note for using NSTextField, if anyone wants to do the extra work. ;-)
http://developer.apple.com/library/mac/#qa/qa1454/_index.html

Taming XCode’s auto-complete options

I am fairly new to XCode and the Objective-C language.
When I am instantiating a class, for example an NSMutableArray, XCode will provide a whole lot of auto-complete options. Even for an empty class which simply extends an NSObject has many options, most of which seem completely useless.
What is the reason for having so many auto-complete options, or can they be "tamed" in the preferences?
EDIT: this is unintentionally a duplicate.
The auto-complete makes coding way faster. For example, in [[NSMutableString alloc] initWithCapacity:5], I only had to type the characters that are in bold face, which is ~ 10/38 = ~26%, so it saves a lot of typing.
That said, it is sometimes unwelcome. You can adjust in "Code Sense" in the Xcode preferences (type COMMAND+COMMA while Xcode is open and in the foreground). You can set the delay for suggestions and also whether it should remember functions you've previously used in that project. You can also disable it completely, if you want to. I don't think you can limit the number of functions it considers, though.

What is the benefit of Xcode's seemingly over-complicated control/outlet workflow?

I'm new to Objective-C, Cocoa, Xcode and Interface Builder. I've got some C background in the past, as well as a fair amount of RealBASIC experience.
I'm working through Mark and LaMarche's iPhone 3 Dev book and I'm really just sort of stunned about how tedious some things are. Maybe someone can shed some light on this for me. My question really is, why does the process for seemingly simple actions involve such a complicated number of steps? Is there a benefit to the complexity which I'll come to love later? Or is it just a brute fact that is unavoidable?
For example, in RealBASIC, if I want a slider's value displayed in a text box, I simply add:
myTextBox.text = mySlider.value
to the slider's Changed event. I can program this in well under 1 minute.
In Xcode/Interface Builder, I have to physically type a declaration for both the text box and the slider, then type a property/outlet declaration for each as well, then create a method declaration and implementation for the ValueChanged even, then set up a (relatively) complicated typecast of the slider's integer value into an NSString using initWithFormat. I then have to return to Interface Builder to link up the controls with the control and method outlets I typed in. I don't see how this can be done in much less than 10 minutes. Maybe 5.
So, what's the benefit of this? Why doesn't Interface Builder automatically create, or at least suggest, control declarations and #property statements, as well as method declarations and implementations? Why can't double-clicking a slider in IB offer you a list of events and offer to automatically insert a skeleton method into your .h and .m file? And why does IB even have to be a separate application?
I'm willing to accept that some of this is my unfamiliarity with all things Xcode, but is this really as efficient as the development environment can be?
My apologies if this is a dead-horse, flame-bait topic with opposing sides on full aggro. If so, please just say "yes, that it is" and move on.
Thanks,
-Rob
A lot of the reasons behind the way IB works will become more clear as you get used to the MVC paradigm.
Once you start using Cocoa Bindings, which update your model when the UI changes and vice versa, you should see an enormous productivity improvement.
I too used to think that Xcode and Interface Builder were unnecessarily complicated, until I worked through a book on both (specifically, Beginning iPhone Development: Exploring the iPhone SDK).
If you're serious about working with Xcode and Interface Builder and are as confused as I was when I started, I highly recommend picking up a book like the one I used. Granted, that was for iPhone development, but I think there is another book by the same publisher (or author) that is straight Mac programming.
Once you work through it and understand what is going on behind the scenes it starts to make a lot more sense. In some ways I prefer IB to things like Expression Blend or XAML for WPF programming in .NET.
Give a book a try and see if it helps :-)
Good luck!

Is there a simple way to combine a text and icon in an NSCell in Cocoa?

I'm trying to create a very simple selection list widget based on NSOutlineView. However, I'm having a hard time figuring out how to display an icon and a label right next to it, which is really the expected behavior in all the mainstream implementations of that kind of widget out there (iTunes, mail, Finder,...).
So far I am just binding two separate cells, but then when I'm expanding the tree, the icon cell grows larger and a gap appears between the icon and its accompanying label. I know I can probably overcome this problem by extending NSCell and provide a custom class, but as what I'm trying to achieve is really the standard thing, I can't be resigned to accept that there isn't a simpler solution.
Candide
Sadly, there isn't a 'text and icon' cell that you can just use, fresh out of the box as you would like. However, when I was working on a project, I found that Apple released some sample code that implements this, since it is such a common idiom.
This can be found here, specifically ImageAndTextCell.h/m
It can help teach you about UI customization by reading through this example, but scratching that, just dropping the ImageAndTextCell straight into your project should do just fine.
You need to create ImageAndTextcell to combine text and icon..
you can create ImageAndTextcell like this Sample Project

Resources