Skip to content
This repository

indicatorYOffset inititialized to 0.0f #6

Merged
merged 1 commit into from about 1 year ago

2 participants

DLC Hesham Abd-Elmegid
DLC

I ran into a very strange case where if I used this control in an archived ipa sent over testflight, the indicatorYOffset when using HMSegmentedControlSelectionLocationUp would be below the frame where it was supposed to be. (Strangely enough it worked fine when attached and debugging with XCode)

photo 1

Once I set this to 0 by default I no longer had the issue. I'm assuming it has to do with the fact that inititalized floats may not have to be zero'd or perhaps because I used a xib. Either way, very strange.

Hesham Abd-Elmegid
Owner

Strange indeed.

Merged, thanks! :smiley:

Hesham Abd-Elmegid HeshamMegid merged commit 8ccd054 into from March 19, 2013
Hesham Abd-Elmegid HeshamMegid closed this March 19, 2013
DLC

I distinctly remember in my C programming course in second year a student arguing that all vars are initialized to 0s and the prof telling him that depending on your implementation of C, it can vary. I can't tell though because in debug mode it worked fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 20, 2013
DLC set yOffset to 0.0f instead of uninitialized. fb18ac8
This page is out of date. Refresh to see the latest.
2  HMSegmentedControl/HMSegmentedControl.m
@@ -153,7 +153,7 @@ - (void)drawRect:(CGRect)rect {
153 153
 }
154 154
 
155 155
 - (CGRect)frameForSelectionIndicator {
156  
-    CGFloat indicatorYOffset;
  156
+    CGFloat indicatorYOffset = 0.0f;
157 157
         
158 158
     if (self.selectionLocation == HMSegmentedControlSelectionLocationDown)
159 159
         indicatorYOffset = self.bounds.size.height - self.selectionIndicatorHeight;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.