Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a wannabe-rubyist who thinks reading Obj-C is somewhere between having a migraine and using H2SO4 eye drops, so far I'm in love with the language. I'm doing lots of tripping over the Cocoa APIs, though, in no small part due to Xcode.

The error messages you get when you've done something wrong are unintuitive at best and downright misleading at worst.

Example: I've got a field I want to render an image in. It's represented as an object of type NSImageCell.

I've got my image file defined as an object of type NSImage. So far, so good.

I type the . after the image cell, and I'm presented with a number of autocomplete suggestions. One of which is a method called "setValue" which accepts an object as an argument.

Okay cool.

    myCell.setValue(NSImage(named: "myImage"))
Compile and.. instacrash with "Unrecognized selector"

What?

Some research turns up that this error means you've tried to send a message to (call a method on) something that doesn't accept that type of message.

Turns out that the method I needed is called setObjectValue. And it also accepts an object as an argument.

So, Xcode. Why did you give me setValue as an autocomplete when it isn't valid on that object? Why are these method names nearly identical? facepalm

And that's before I get into the almost completely worthless inline error messages. "Cannot convert to $T1". What?

I really, really like the language, but Xcode is trying its damndest to turn me away. I've got a stack of bugs/feature requests that need to be entered into Apple's reporting tool - hopefully some of these are just warts that'll get fixed as Xcode 6 comes out of beta.



It's still in beta dude. Night and day difference between beta and gold master. If you're turned away from a brand new language due to an IDE's autocomplete, then you're in for a world of hurt when you start learning all the Cocoa APIs.


Sure, and he acknowledged that they're still working on it, and is filing bug reports ;)

Having new people join a project/language, and finding it's warts/weird parts is awesome! It's part of how you learn where the REAL issues that bother people are, and set a development roadmap. He's using it, and telling Apple where it should evolve. That's the whole -point- of a Beta ;)


Heh, this is the truth. Most of the difficulty of learning Swift I think will lie in learning Cocoa. Just like Objective-C that.


That is true for every programming language and platform pair. The syntax is always the easy part, but unfortunately the only thing most people fixate on.


Valid point, also amusing that everyone focuses on the trivial part of syntax over the difficulty of the environment it lives in.


That setValue(AnyObject)->Void autocompletion is interesting. I don't believe any such method exists anywhere in Cocoa. I think it's probably a bug where a spurious method declaration is being generated from the NSKeyValueCoding protocol header based on setValue:forKey:.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: