Tags in Swift

49 views
Skip to first unread message

Terrill Thorne

unread,
Jan 18, 2015, 12:06:59 AM1/18/15
to swift-l...@googlegroups.com
How can I write a tag in a line of code?

Marco S Hyman

unread,
Jan 18, 2015, 12:20:43 AM1/18/15
to Terrill Thorne, swift-l...@googlegroups.com

> On Jan 17, 2015, at 9:06 PM, Terrill Thorne <rm250r...@gmail.com> wrote:
>
> How can I write a tag in a line of code?

Some context, please. What kind of tag?

HTML tag?
XML tag?
Image metadata tag?
Finder tag?
Graffiti signature?
QR code?
Something else that I'm not thinking of right this second?

Terrill Thorne

unread,
Jan 18, 2015, 12:29:23 AM1/18/15
to swift-l...@googlegroups.com, rm250r...@gmail.com
I can't remember which tag it's called but the tag is under "view" in Xcode. 

Jens Alfke

unread,
Jan 18, 2015, 1:12:42 AM1/18/15
to Terrill Thorne, swift-l...@googlegroups.com

On Jan 17, 2015, at 9:29 PM, Terrill Thorne <rm250r...@gmail.com> wrote:

I can't remember which tag it's called but the tag is under "view" in Xcode. 

Well, once you figure out what it is you’re asking for, come back and ask it.

—Jens

Ken Ferry

unread,
Jan 18, 2015, 1:43:41 AM1/18/15
to Jens Alfke, Terrill Thorne, swift-l...@googlegroups.com
Sounds like the question is about -[UIView tag]. 

It'd be 
  myView.tag = 3

-ken


Sent from Mailbox


--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swift-languag...@googlegroups.com.
To post to this group, send email to swift-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/3A5B7C4F-E761-4BA1-94C6-0BBFB5C4DAD8%40mooseyard.com.
For more options, visit https://groups.google.com/d/optout.


Darrell Nicholas

unread,
Jan 24, 2015, 6:26:29 PM1/24/15
to swift-l...@googlegroups.com
var imageView.image = UIImage(named:"someImage")
imageView.tag = 1

let myLabel:UILabel = cell.contentView.viewWithTag(5) as UILabel

I think that's the way it's done. (This is all from memory, I could be wrong, but you may have to call view methods on what you want to set the tag value on then cast it using the "at" keyword to whatever it actually is. ex. UILabel, UITextField, UIImageView, and so on.

Darrell Nicholas

unread,
Jan 24, 2015, 6:42:47 PM1/24/15
to swift-l...@googlegroups.com, rm250r...@gmail.com
This is the kind of response that causes us in the developer community to have a "stuck up" attitude and ticks me off. I'm sorry, but if you can't tell from the sentence 

"I can't remember which tag it's called but the tag is under "view" in Xcode.", 

what tag they are talking about....then maybe you need to come back when you are more qualified to answer a question. There ain't no Swift experts outside of Apple. NOBODY has used the language for a year yet. So if someone is humble enough to ask a question, then we need to be kind enough to answer it. I doubt you learned everything about programming from reading the Apple Documentation. I'm willing to bet that somewhere, somehow, somebody in the past shared some information with you. If you need more clarification, then ask for clarification. 

I'm self taught, and I learned a lot by hard work. I asked a lot of questions and some people were kind of hateful when I didn't ask the question in the "right" way. The developer community will remain a relatively closed community because of the complexity of programming itself. We don't have to run off people or haze newcomers. Matter of fact, we might need to encourage more people to learn what we know so that we will be compelled to get better ourselves.

You notice how I am being hateful, yet giving you the benefit of the doubt that you know your stuff? You may not know what a tag on a view is or how to set it outside of the Storyboard. If you want, I'll explain it in greater detail. If you ask the right way...

Jens, if you need anymore help, ask here again and I'll look it up and be sure to give you the correct answer. I know how it's done in Objective-C and I believe my other answer is either right or close to right. Don't give up asking. If you get any more rude answers here, go to raywenderlich.com and you WILL find a tutorial about just anything you need to know. Also, skipcasts.com is a great Swift resource. Shinobicontrols.com has a great book you can get for free for signing up for a newsletter. The REAL experts hang out on stackoverflow.com and there are some that are friendly and some not so much. But if someone puts the right answer up, other people will up vote the answer. That's where I turn when I have a question I can't figure out when I'm developing my own custom products.

Never quit in the pursuit. Nobody knows everything about any language.

-Darrell

Jens Alfke

unread,
Jan 25, 2015, 5:26:07 PM1/25/15
to Darrell Nicholas, swift-l...@googlegroups.com, rm250r...@gmail.com
On Jan 24, 2015, at 3:42 PM, Darrell Nicholas <darrellw...@gmail.com> wrote:

This is the kind of response that causes us in the developer community to have a "stuck up" attitude and ticks me off. I'm sorry, but if you can't tell from the sentence 

"I can't remember which tag it's called but the tag is under "view" in Xcode.", 

what tag they are talking about....then maybe you need to come back when you are more qualified to answer a question.

No, I couldn't tell, and it had nothing to do with my qualifications; the question itself was hopelessly vague. And what you're quoting wasn't even his original question! He originally asked "How can I write a tag in a line of code?" That was literally the entire message. After someone pointed out that this was too ambiguous to be answerable, he expanded it to what you quoted. Which was still not useful, and also, honestly, lazy. If Terrill "can't remember which tag it's called", then he can go back and look again so that his question has the necessary info. After those two messages I gave up.

So if someone is humble enough to ask a question, then we need to be kind enough to answer it.

Sorry, nope. I don't need a lecture on answering questions — I answer a literal fuckton of questions on Apple's developer mailing lists and on the mailing list for my work project. I've been answering (and asking) questions on mailing lists and Usenet since the '80s. (And it may not be relevant, but I created this Google group, soon after Swift was announced, so that there'd be a good forum for people, including me, to ask questions and discuss it.)

I understand what you mean by "humble", but honestly, some people who ask questions have a very entitled attitude: that the people they're writing to are supposed to solve their problem for them and that they don't need to make it easy to answer. Many times I've gone around and around with someone, coaxing them to give out the necessary context that they could easily have provided up front. (What OS was this? What was the error message you got? What is the actual task you're trying to accomplish? What steps caused this to happen? Does this happen every time? Could you paste the exact code instead of typing something in from memory that obviously doesn't even compile? Etc.) There are even people who are very obviously asking mailing lists to provide complete solutions for their homework problems.

Asking a uselessly vague question is not humble, it's careless and entitled. It shows a lack of respect for the time of the people on the list.

I'm not the only one who gets frustrated. There is a whole genre of online essays about How To Ask Good Questions, written by people who are helpful but frustrated by the exact problems I'm describing. There is the term "help vampire" that describes the very real personality type that demands that other people online solve their problems for them. There is the site lmgtfy.com whose purpose is to shame people who would rather not look for answers themselves.

I doubt you learned everything about programming from reading the Apple Documentation. I'm willing to bet that somewhere, somehow, somebody in the past shared some information with you. If you need more clarification, then ask for clarification. 

Believe me, I ask questions too. I'm always trying to learn new stuff, and when I get stuck I ask for help. And when I do I make sure to get to the point, include all the necessary context, and generally make it as easy as possible for someone to help me, because I am very aware that they are donating that time out of the goodness of their heart.

And I did ask for clarification. I pointed out that the question was too vague and invited him to find out what this "tag" he was looking for was and post a better question. And yes, I did it in a somewhat snarky way, to send a message that what he was doing was inappropriate.

Jens, if you need anymore help, ask here again and I'll look it up and be sure to give you the correct answer. 

Um, the guy asking the question was named Terrill.

—Jens

PS: Sorry this turned into a rant. As you can tell, it's a bit of a sore spot for me, and I usually bite my tongue and just ignore lame questions. I'm also for unrelated reasons having a bad day today and am in a grumpy mood, so you set off the flame-bot. Nothing personal.

Darrell Nicholas

unread,
Jan 25, 2015, 6:35:50 PM1/25/15
to swift-l...@googlegroups.com, darrellw...@gmail.com, rm250r...@gmail.com
Sorry about getting you mixed up with the asker. I was on a rant too. Yes his question was too vague in the beginning, but from the way the posts were displayed on my screen, he had been asked for clarification and had came back with it. I knew what he was talking about. That's why I quoted it. Yes I know there have been some great articles about the proper way to ask questions, the one that comes to mind is by Ash Furrow. 

But look, there's a TON of new coding bootcamps popping up, tutorial sites everywhere, and the bottom line is there are about to be a lot of people on every forum asking questions the wrong way. When I first started I didn't ask a question for a whole year online because I didn't want to look stupid or have someone smart off to me and make me quit learning. I didn't grow up in an area where there are any universities, much less colleges or high schools, that taught any form of computer science.

I didn't have a CHANCE to learn back in the 80's when I was really wanting to. It wasn't until much later in life that I had the resources, and a good enough job, that I could take the time to start learning on my own. Things are better here nowadays (in rural Arkansas) and maybe people who have the passion to learn can have a better chance at doing so.

I just hope that nobody gets too scared to ask questions and gives up on a dream because they didn't know how to ask in the right way.

I sincerely hope you have a better day. I also want to thank you for taking the time to start this group. Once again, I apologize for getting you mixed up with Terrill. 

I don't know any other way to put it, fucking be nice! It won't kill you. If you don't want me in your group, I won't visit again. I will always say what I think and feel. Life's too short and I'm too old to hold back now.

That's all I got to say on the subject.

Jens Alfke

unread,
Jan 25, 2015, 7:12:24 PM1/25/15
to Darrell Nicholas, swift-l...@googlegroups.com, rm250r...@gmail.com
On Jan 25, 2015, at 3:35 PM, Darrell Nicholas <darrellw...@gmail.com> wrote:

Yes his question was too vague in the beginning, but from the way the posts were displayed on my screen, he had been asked for clarification and had came back with it. I knew what he was talking about. That's why I quoted it.

Honestly his second question didn't make any more sense to me than the first — I think because "under view in Xcode" made me think of the View menu, which made me think he was asking something like tagging lines in the editor (like the way you can in TextMate, for example.)

But look, there's a TON of new coding bootcamps popping up, tutorial sites everywhere, and the bottom line is there are about to be a lot of people on every forum asking questions the wrong way.

This is a good point. I'm not sure how to answer it, because while these people really do deserve support, it is a big time-sink to shoot a vague unanswerable question to a large number of people, a couple of whom will spend time writing back to ask for clarification or answering a different question that they thought was being asked, and then having to iterate over that a few times.

(Old Usenet clients like "rn" used to come with a warning that popped up the first time you posted — something like "This post is going to be sent to thousands of computer systems and be read by hundreds of people. Are you sure it's worthwhile and clear?")

When I first started I didn't ask a question for a whole year online because I didn't want to look stupid or have someone smart off to me and make me quit learning. I didn't grow up in an area where there are any universities, much less colleges or high schools, that taught any form of computer science.

I've almost never seen someone be flamed simply for not knowing things. What tends to bug people is communication problems — not asking comprehensibly, not listening to earlier answers, asking the same thing over and over, demanding answers. Sometimes this is just lack of fluency (lots of people don't speak English natively) but in a small fraction of cases it's basically just rude and I will call people on that.

I don't know any other way to put it, fucking be nice! It won't kill you.

I think that I've contributed a lot of information to people over the years, on a lot of forums, with about a 99.5% politeness record. So I'll take a pass on the lecture, if you don't mind.

—Jens
Reply all
Reply to author
Forward
0 new messages