-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Reachability.m #123
Open
lucaseverini
wants to merge
1
commit into
tonymillion:master
Choose a base branch
from
lucaseverini:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there, I saw your fix and wanted to leave a little feedback. I've been monitoring this issue closely I think you're the fourth person now I've interacted on a PR with :)
At line 98 retain count of the ref will be 1, due to the create.
We don't know immediately what the init does, so lets assume it doesn't retain it.
Now here on 102, you release ref. Its retain count is now 0. You will have created a zombie
(Final note) The init doesn't retain it, so all the above assumptions are true. Try and run the app with your changes, the reachability class will hit a zombie. See my solution #118 for the full fix. You are correct in that you whenever you create a foundational item you should release it. However what you, and a couple others, ran into was the assumption that the init takes ownership. Which it doesn't at the moment. If you update the init to take ownership then your fix will be complete. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you did. I missed it and I assumed you did what others did before.
You can disregard my above comments.
However, I'd like to leave 2 cents if you don't mind :)
Not sure about everyone else but for me your fix is a little hard to read. I totally glanced over your retain statement. Since the ultimate (final) release is in the dealloc, I think many people would expect the retain to happen in the init. Instead of all the helpers that call the init. And while there may not be additional helpers being added any time soon, if someone does, they'll have to be sure to make the retain in their new helper. Since the current helpers are class methods, it does feel a little odd its doing memory management on an instance item.
Again, just my two cents & it may be a little nit-picky, but feels a little anti-pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As much as the analyzer doesn't report possible problems, I don't really care what solution is bes among those two. They both look fine to me.
However don't blame others if you don't read code carefully... ;-)