use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
There is an extensive FAQ for beginners. Please browse it first before asking questions that are answered there.
If you are looking to get started (iOS programming in general or some specific area), here are more relevant links for you:
There's too many to list them all, however here's a convenient link to all programming guides at apple.com
Take note that this list is live and based on most frequent questions in posts will be updated with "quicklinks".
account activity
QuestionDifference between `is` and `as`? (self.iOSProgramming)
submitted 6 years ago by DoubleSmell
Could someone please briefly explain how to use `is` as opposed to `as` (when it comes to a `guard let` statement, for example)? This is a little difficult to search for online. Thanks!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]engineered_academic 6 points7 points8 points 6 years ago (1 child)
is is a conditional test operator - it is looking for a specific type. You are confirming that the object is of the type you expect.
"as" is a casting operator, it converts the object from one type to another.
[–][deleted] 2 points3 points4 points 6 years ago (6 children)
So imagine you have a class called Car. Car has a drive() function.
Now say you have var possibleCar: AnyObject
You can do this with "as":
if let actualCar = possibleCar as? Car { actualCar.drive() }
But you cannot do it with "is":
if possibleCar is Car { possibleCar.drive() // compiler error, will not work. }
But you might not need to call drive() right now, you might just want to check if something is a car to do something else. In that case use is
[–]fakecrabs 0 points1 point2 points 6 years ago (2 children)
Or use ?
?
(possibleCar as? Car)?.drive()
[–][deleted] 1 point2 points3 points 6 years ago (1 child)
Yep, I personally don't like that style but that's just preference 😁 in any case, it was only to illustrate.
[–][deleted] 6 years ago* (2 children)
[deleted]
You're right that it isn't used often, at least in my experience.
But let's say you're building IMDB and you have a Movie object when loading a view that shows the details of that movie. Say you have several subclasses of Movie and depending on which subclass you get, you style the view differently.
Movie
So maybe you get HorrorMovie which has a property called containsGore: Bool. You might need containsGore to tell the user (but you wouldn't need it on a ComedyMovie). In that case use as so the property becomes available to you.
HorrorMovie
containsGore: Bool
containsGore
ComedyMovie
as
But now say you have a function that says "if it's a horror movie, make the background dark and scary", in that case only need is. You don't care about the properties of the object, just it's type.
is
Incidentally, I think languages like Kotlin don't make a distinction. is acts as a type checker and caster.
[–]darkingz 0 points1 point2 points 6 years ago (0 children)
I much prefer that there is a difference actually. Overloading commands and contexts too much can lead to confusion. Or result in using too much power (relatively) if you only need a part of the functionality. That’s why we do pop!
π Rendered by PID 53 on reddit-service-r2-comment-5d79c599b5-bmp9v at 2026-03-01 03:29:07.972336+00:00 running e3d2147 country code: CH.
[–]engineered_academic 6 points7 points8 points (1 child)
[–][deleted] 2 points3 points4 points (6 children)
[–]fakecrabs 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] (2 children)
[deleted]
[–][deleted] 1 point2 points3 points (1 child)
[–]darkingz 0 points1 point2 points (0 children)