First of all, we have this question from four years ago:
Check if a subview is in a view
Despite carrying an Objective-C tag, ultimately this question is purely just asking about an object/method out of UIKit
, which is one of the frameworks for writing iOS application. And even though the "pseudocode" looks quite like Objective-C, it's still not Objective-C:
if([self popoverView] is not on rootView)
As far as I'm concerned, there's not really much wrong with this question. It's a perfectly valid question about the UIKit
framework. But let's keep in mind, it's not a language specific question, not really.
Then we have this question:
Check if a subview is in a view using Swift
This question asks the same question... but instead specifies "But all the answers are in Objective-C, and I want to know how to do it in Swift?" It even links back to the question I referenced earlier in this post. And that original answer has a link back to the official UIView
documentation, which between the posting and now, that link has been updated to include the Swift implementation of the answer.
In fact, outside of the Objective-C-looking "pseudocode" and the language tag (since 4 years ago ObjC would've been the only language that applied), that original question doesn't even specify that answers should be in Objective-C.
So, with all that said...
In my opinion, it seems the best course of action would be to do the following:
- Edit the original question's "pseudocode" to look less like Objective-C and more like legitimate pseudocode. Also fix up its tags to better reflect what the question is actually about (remove objective-c, add uikit and perhaps uiview).
- Edit the accepted answer on the original question to additionally include the Swift syntax, since ultimately the answer is just (correctly) pointing to the
UIView
documentation, which documents both Swift and Objective-C (and would document any new language Apple adds in the future). - Close the new question as a duplicate of the original question.
I want to elaborate on point 3. I don't think that all Swift questions can or should be closed as duplicates of Objective-C questions. But when the question isn't about a specific problem with the Swift syntax and is purely asking the same library/framework question as an existing Objective-C question, then it's the same question. In this specific case, I personally feel relatively strongly that the question could be closed as a duplicate without any edits to the older question.
Am I right in this? Or should we let the Swift question stand in this specific case?
Addendum: Now that I look more closely, someone actually did add a Swift answer to that original question.