Skip to content

Commit

Permalink
Fixed bug with delegate deglaration
Browse files Browse the repository at this point in the history
- Fixed issue #4
  • Loading branch information
Boris-Em committed Jun 9, 2014
1 parent 7f3d611 commit 27ac392
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Classes/BEMAnalogClockView.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//------------------------------------------------------------------------------------//

/// BEMAnalogClockView delegate object is essential to the clock. The delegate provides the clock with data and various parameters. The delegate can be set from the interface or from code.
@property (nonatomic, weak) id <BEMAnalogClockDelegate> delegate;
@property (nonatomic, assign) IBOutlet id <BEMAnalogClockDelegate> delegate;


//------------------------------------------------------------------------------------//
Expand Down
16 changes: 12 additions & 4 deletions Classes/BEMAnalogClockView.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ - (void)layoutSubviews {
[panView addGestureRecognizer:panGesture];
}

if ([self.delegate respondsToSelector:@selector(currentTimeOnClock:Hours:Minutes:Seconds:)]) {
[self.delegate currentTimeOnClock:self Hours:[NSString stringWithFormat:@"%li", (long)self.hours] Minutes:[NSString stringWithFormat:@"%li", (long)self.minutes] Seconds:[NSString stringWithFormat:@"%li", (long)self.seconds]];
}
shouldUpdateSubviews = NO;

if ([self.delegate respondsToSelector:@selector(clockDidFinishLoading:)])
[self.delegate clockDidFinishLoading:self];
}
Expand All @@ -215,7 +217,9 @@ - (void)updateEverySecond {
[self timeFormatVerification];

[self.animationDelegate rotateHand:self.secondHand rotationDegree:[self degreesFromMinutes:self.seconds]];
if ([self.delegate respondsToSelector:@selector(currentTimeOnClock:Hours:Minutes:Seconds:)]) {
[self.delegate currentTimeOnClock:self Hours:[NSString stringWithFormat:@"%li", (long)self.hours] Minutes:[NSString stringWithFormat:@"%li", (long)self.minutes] Seconds:[NSString stringWithFormat:@"%li", (long)self.seconds]];
}
}
}
}
Expand Down Expand Up @@ -246,8 +250,9 @@ - (void)updateTimeAnimated:(BOOL)animated {
self.hourHand.transform = CGAffineTransformMakeRotation(([self degreesFromHour:self.hours andMinutes:self.minutes])*(M_PI/180));
self.secondHand.transform = CGAffineTransformMakeRotation(([self degreesFromMinutes:self.seconds])*(M_PI/180));
}

if ([self.delegate respondsToSelector:@selector(currentTimeOnClock:Hours:Minutes:Seconds:)]) {
[self.delegate currentTimeOnClock:self Hours:[NSString stringWithFormat:@"%li", (long)self.hours] Minutes:[NSString stringWithFormat:@"%li", (long)self.minutes] Seconds:[NSString stringWithFormat:@"%li", (long)self.seconds]];
}
}

- (void)setClockToCurrentTimeAnimated:(BOOL)animated {
Expand All @@ -274,8 +279,9 @@ - (void)setClockToCurrentTimeAnimated:(BOOL)animated {
self.hourHand.transform = CGAffineTransformMakeRotation(([self degreesFromHour:self.hours andMinutes:self.minutes])*(M_PI/180));
self.secondHand.transform = CGAffineTransformMakeRotation(([self degreesFromMinutes:self.seconds])*(M_PI/180));
}

if ([self.delegate respondsToSelector:@selector(currentTimeOnClock:Hours:Minutes:Seconds:)]) {
[self.delegate currentTimeOnClock:self Hours:[NSString stringWithFormat:@"%li", (long)self.hours] Minutes:[NSString stringWithFormat:@"%li", (long)self.minutes] Seconds:[NSString stringWithFormat:@"%li", (long)self.seconds]];
}
}

- (void)startRealTime {
Expand Down Expand Up @@ -317,7 +323,9 @@ - (void)handlePan:(UIPanGestureRecognizer *)recognizer {
self.minuteHand.transform = CGAffineTransformMakeRotation(angleInRadians + M_PI/2);
self.hourHand.transform = CGAffineTransformMakeRotation(([self degreesFromHour:self.hours andMinutes:self.minutes])*(M_PI/180));

[self.delegate currentTimeOnClock:self Hours:[NSString stringWithFormat:@"%li", (long)self.hours] Minutes:[NSString stringWithFormat:@"%li", (long)self.minutes] Seconds:[NSString stringWithFormat:@"%li", (long)self.seconds]];
if ([self.delegate respondsToSelector:@selector(currentTimeOnClock:Hours:Minutes:Seconds:)]) {
[self.delegate currentTimeOnClock:self Hours:[NSString stringWithFormat:@"%li", (long)self.hours] Minutes:[NSString stringWithFormat:@"%li", (long)self.minutes] Seconds:[NSString stringWithFormat:@"%li", (long)self.seconds]];
}
}

#pragma mark - Conversions/Calculations
Expand Down
9 changes: 6 additions & 3 deletions Sample Project/BEMAnalogClock/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="QCb-ZU-fSV">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="QCb-ZU-fSV">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
Expand Down Expand Up @@ -42,6 +42,9 @@
<rect key="frame" x="60" y="99" width="200" height="200"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="darkTextColor"/>
<connections>
<outlet property="delegate" destination="vXZ-lx-hvc" id="aqB-Eh-ZiI"/>
</connections>
</view>
<view alpha="0.89999999999999991" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4UQ-lJ-0NJ">
<rect key="frame" x="0.0" y="380" width="320" height="100"/>
Expand Down Expand Up @@ -94,4 +97,4 @@
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
</document>

0 comments on commit 27ac392

Please sign in to comment.