|
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 AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.