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

text field returning seems cumbersome the way @pasan does it (interactive story app)

the way Pasan Premaratne decides to move the text field back seems like a lot of unnecessary code. I simply put textFieldBottomConstraint.constant = 40 under the textFieldShouldReturn func and it works perfectly with 1 line of code.

pasan made an entirely new notification observer and added a new function, when all I did was add the new constraint to the already made textFieldShouldReturn function. Is what I did bad practice? why would I do it pasan's way with way more code?

1 Answer

Hi Taylor,

Neither is wrong, what Pasan's way is more scalable if you'd want to add more functionality (and he always encourages that). Your solution is straight to the point and serves its purpose. However, if you'd want to change the constraint dynamically (given some even or few events), it would be easier to do by going Pasan's way. Hope this helps, if not let me know I'll delve deeper.