36

While I am using this specific answer as an example, I am asking this in a broader sense. I tend to find Swift answers added to old Objective-C questions very often when searching for solutions on Stack Overflow. Is this detrimental to the sites search abilities? Wouldn't it be better for new questions to be asked in their respective language rather than just updating all the old Objective-C questions with new Swift answers? Should I be flagging these? It just feels odd having multiple language answers on one question.

I've read over Is it acceptable to post answers in Swift on iOS/OS X questions marked with the Objective-C tag and vice versa?, but it seems to be more concerned with newly asked questions, and doesn't really have a clear acceptable solution.

1
  • Maybe if it's Swift 2.0. But Swift 1.2 answers on any questions are practically worthless, and provides negative value. Commented Aug 27, 2015 at 15:43

2 Answers 2

50

For that question, nothing in it states that they're only looking for Objective-C answers, just solutions for iOS. That would seem to leave the door open for Swift answers.

The Swift version of this has enough of a difference in structure that I could see the utility in having it there for a quick reference. Also, they add a screenshot of something else to be aware of when using this, so they add to the answers there.

I see no reason to remove this, and I don't think I'd go out of my way to flag them. I'm not excited about encouraging people to go back and copy Objective-C answers in Swift all over the place, but if the question isn't asking for answers in a specific language I don't see a real problem with them.

7
  • 1
    Since the OP mentions tags, too, if a Swift answer is acceptable and helpful, should a Swift tag be added to the question in question? Commented Aug 25, 2015 at 14:01
  • 18
    @AdamMiller - Why add one? If the asker had not restricted the question to a specific language, why add that restriction based on an answer? Commented Aug 25, 2015 at 14:18
  • 7
    I've never seen the tags as restrictions, but descriptions. They don't confine anything, but help with searching and categorization. Commented Aug 25, 2015 at 14:26
  • 9
    @AdamMiller: They do function as restrictions in practice, however. If the question had originally been tagged objective-c, then the Swift answer would be dismissed as not meeting the requirements. (That's not justification for flagging it... but snippets of other languages found in answers are basically equivalent to pseudocode, not code)
    – Ben Voigt
    Commented Aug 25, 2015 at 17:48
  • 6
    Can't just both "objective-c" and "swift" tags be added? Commented Aug 25, 2015 at 20:35
  • 3
    @JoseGómez there's nothing on the question itself that hints that a language specific solution is needed. If the question body itself doesn't make reference to neither objc nor swift, adding the tag is counterproductive.
    – Braiam
    Commented Aug 26, 2015 at 14:38
  • I agree with @Jose Gómez. I am preety new to iOS development and have only 2 Apps. I still develop in objective-c. But the iOS versions are moving on. So there are cases in which you see answer in Swift, but you need objective-c solution. Commented Aug 27, 2015 at 16:27
31

Speaking as someone who is a new iOS developer and has only learned Swift, I can say, yes, Swift answers in Objective-C questions are very beneficial. I've been helped countless times by them. There is far too little Swift documentation out there and trying to guess the Swift syntax by looking at Objective-C is a headache, especially in the beginning. The best is probably when a quality answer shows both Swift and Objective-C syntax, but when that doesn't happen, having a Swift version somewhere down the line of answers is a good second best.

That said, I wish the high rep users would be a little more lenient about letting new Swift "duplicate" versions of Objective-C questions go. These users are almost always already very competent in Objective-C and don't seem to understand what it is like to start from scratch with Swift. Even for questions that are general iOS and could take either Objective-C or Swift answers, it would still be very helpful to have a Swift only version of the question. Most of the popular old questions are bogged down with Objective-C answers and it takes forever for the good Swift answers to rise to the top. I've wasted I don't know how much time scrolling through Objective-C answers before finding a Swift one somewhere down near the bottom.

One of the biggest benefits of SO (to me anyway) is getting useful answers quickly. Allowing Swift and Objective-C answers to swim together is useful, but to require it is unnecessary at best and counterproductive in many cases.

3
  • 1
    +1 Basically what I was going to say. They are very helpful, as a new(ish) Swift developer.
    – rocket101
    Commented Aug 26, 2015 at 11:57
  • I rant similar and get downvoted 'cause it's seen as just complaining from me, which is understood. But seeing you rant about the same things from an actual beginner's perspective is refreshing. Yes, you are dead on. Sometimes the functions aren't available either, or throw an exception ( uiimagejpegrepresentation) and swift won't (in 1.x) handle it. Also, splitting a UIImage into subpieces still takes ARC-bridging.
    – Stephen J
    Commented Aug 26, 2015 at 20:49
  • 2
    I agree completely. It is not just the person asking the question that should benefit from the answer. The way that I use StackOverflow is to find nuggets of code that some my problem from anywhere on the thread. If the answer I need is in Objective C then I am getting better at translating it but I am alway happy to see Swift versions that I can just copy and paste.
    – iphaaw
    Commented Aug 27, 2015 at 11:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .