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 Intermediate Swift Extensions and Protocols Extending a Native Type

Harris Ryder
Harris Ryder
1,333 Points

Stuck on this task, I think Im quite close but dont quite know what its asking for, Thanks!

Ive watched the video many times and I am still stuck on the problem, I think my issue is understanding the question

types.swift
// Enter your code below

extension String {

var add: Int {

     return Int(self)! + 1


}

"1".add





}

1 Answer

vinona weil
seal-mask
.a{fill-rule:evenodd;}techdegree
vinona weil
Front End Web Development Techdegree Student 1,224 Points

// Enter your code below extension String { func add(number: Int) -> Int? { guard let convertedNumber = Int(self) else { return nil } return convertedNumber + number } }