Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Vending Machine App in Swift Using the Vending Machine Testing Out the Vending Machine

Zenek Barburka
Zenek Barburka
7,009 Points

Let's chenge the name....????

at 5:49 you decide to change the name of the arguments everywher in the code. I get that that something you may need to do once you code, but for the sake of clarity of this video and it's purpose (EDUCATIONAL) you should really avoid distrctions like that.

3 Answers

Xavier D
PLUS
Xavier D
Courses Plus Student 5,840 Points

Hi,

I thought changing the name would, should I say, "open up a can of worms"... but I remembered a nifty trick that I I used with MS Word...which is the "Find & Replace" function!

Thus, when Pasan requested us to change the parameter names around in the vend function for better readability, I navigated to the Xcode menu bar and selected, "Find and Replace in Project" from the "Find" menu. To the left of the standard editor, that opened up two text fields to input what you want to find and replace respectively.

So in the first text field, I put:

vend(_ quantity: Int, _ selection: VendingSelection) throws

and in the second text field I put:

vend(selection: VendingSelection, quantity: Int) throws

From there I pushed "return" on my keyboard and Xcode found two results, which matches the same amount of errors that were created because of the change. From there, I clicked on the option to "Replace All" and, "Voila!" No more errors regarding that method, and I didn't have to search thru the code to fix it, I just let Xcode do it for me.

Now since I was a PC prior to a Mac (i.e. since I was using MS Windows before using Mac OS X), using Windows MS Word was like second nature, and since the word processor has hints of a text editor, I figured Xcode's Standard editor had a similar Find/Replace functionality. Heck, the shortcut command on Word (Ctrl + F) is almost like how it is on Mac (Command + F). Pasan may not have been a Windows user prior to a Mac, and if not, he probably may not know about Ctrl + F in Word.

Now I know some Mac users would not touch Microsoft software, and for the most part, once I went Mac I never went back. Well...actually I went back a bit, not using Time Machine (e.g.the Time Machine app along with Time Capsule HDD), but with a virtual machine like Parallels or VMware, or with Bootcamp using Mac hardware...

Anywho, Find/Replace can save a lot of headaches if you happen to need to rename stuff in your code (and I'm always renaming stuff in my codes; searching thru them all would be very painstaking)...and I never would've thought of using this functionality if it weren't for my prior experience with Office.

Hope this helps...

XD

If this was C or objective C you could select that which you want to change the name of, right click: refactor > rename, and XCODE would do the work for you, but sadly xcode does not have this implemented yet

It is nice to see the frustration associated right with the video and not hidden in the forums. Man, this course is tiresome.

Paolo Scamardella
Paolo Scamardella
24,828 Points

This course is tiresome? Then you need to quit! Pasan is trying to teach everyone the right way instead of writing unmaintainable, untestable, non-flexible, and a cluster-f### code. Try to write unmaintainable code and see how far you will get in the tech industry.

People who complains about name changing for the better should just quit and change profession. I see refactoring code on a daily basis, and it is part of an every day life of a developer.

I'm actually enjoying this course because of the way Pasan is structuring/architecturing the app. This is something that I don't see very ofter by other teachers.

Anyone can write code, but try structuring an app that should be flexible in the future is not so easy! This is what Pasan is trying to teach.

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! When you post here to the Community you are (for the most part) addressing other students. I will say that Treehouse staff does love feedback and suggestions, though. Might I suggest that you send your suggestions about this video to the staff? You can email them at help@teamtreehouse.com. Hope this helps! :sparkles: