|
Wondering if anyone can spot why the following doesn't correctly identify all positive search results:
For example, if searchTerm =
|
|
The way you have your check set up, if one of the books does not match, all previous matches get cleared out of your result array:
So let's walk it through...
You don't need the You can easily see what's going on if you stick some |
|
@rooster has the right answer! May I add a comment? You have the start of a
Consider moving Book related logic to your
By encapsulating business logic in your
Homework problem: How might you create a I agree with @rooster. Think of better names for both Keep coding! |
|
Heck, go even further and pull out the array-searching logic into an extension:
Then you can just do this to get an array of
|
|
Thanks for the assists, @roosterboy & @Obelix! I've been able to fix the logic and simplify the code (including moving I'll hold off applying the |
SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.