Permalink
Browse files

Added method retweet

  • Loading branch information...
1 parent 1193f7c commit ca317beee5533aa6416c7445be9445c275586351 @lucascorrea committed Mar 5, 2012

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -59,5 +59,6 @@ typedef void(^SCTwitterDirectCallback)(BOOL success, id result);
+ (void)getUserInformationCallback:(void (^)(BOOL success, id result))aCallback;
+ (void)getUserInformationFor:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
+ (void)directMessage:(NSString *)message to:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
++ (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id result))aCallback;
@end
@@ -35,6 +35,7 @@ - (void)getPublicTimelineWithCallback:(void (^)(BOOL success, id result))aCallba
- (void)getUserTimelineFor:(NSString *)username sinceID:(unsigned long)sinceID startingAtPage:(int)page count:(int)count callback:(void (^)(BOOL success, id result))aCallback;
- (void)getUserInformationFor:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
- (void)directMessage:(NSString *)message to:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
+- (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id result))aCallback;
- (BOOL)isSessionValid;
@end
@@ -127,6 +128,11 @@ + (void)directMessage:(NSString *)message to:(NSString *)username callback:(void
[[SCTwitter shared] directMessage:message to:username callback:aCallback];
}
++ (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id result))aCallback
+{
+ [[SCTwitter shared] retweetMessage:updateID callback:aCallback];
+}
+
#pragma mark -
#pragma mark Private Methods
@@ -256,6 +262,27 @@ - (void)directMessage:(NSString *)message to:(NSString *)username callback:(void
}
}
+- (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id result))aCallback
+{
+ if (![self isSessionValid]) {
+
+ // Call the login callback if we have one
+ if (aCallback) {
+ aCallback(NO, @"Error");
+ }
+
+ }else{
+
+ if (updateID == nil) {
+ aCallback(NO, @"No updateID");
+ return;
+ }
+
+ self.statusCallback = aCallback;
+ [_engine sendRetweet:updateID];
+ }
+}
+
#pragma mark -
#pragma mark - SA_OAuthTwitterControllerDelegate methods
@@ -19,5 +19,6 @@
- (IBAction)userTimelineButtonAction:(id)sender;
- (IBAction)userInformationButtonAction:(id)sender;
- (IBAction)directMessageButtonAction:(id)sender;
+- (IBAction)retweetButtonAction:(id)sender;
@end
@@ -157,6 +157,21 @@ - (IBAction)directMessageButtonAction:(id)sender
}];
}
+- (IBAction)retweetButtonAction:(id)sender
+{
+ [SCTwitter retweetMessage:nil callback:^(BOOL success, id result) {
+ loadingView.hidden = YES;
+
+ if (success) {
+ //Return array NSDictonary
+ NSLog(@"%@", result);
+ }else{
+ NSLog(@"%@", result);
+ }
+ }];
+
+}
+
#pragma mark -
#pragma mark - UITextFieldDelegate methods
@@ -18,7 +18,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="XDM-n1-1r6">
- <rect key="frame" x="35" y="86" width="120" height="37"/>
+ <rect key="frame" x="35" y="83" width="120" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Login" backgroundImage="backgroundButton.png">
@@ -33,7 +33,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="YwI-AH-qCi">
- <rect key="frame" x="165" y="86" width="120" height="37"/>
+ <rect key="frame" x="165" y="83" width="120" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Logout" backgroundImage="backgroundButton.png">
@@ -48,7 +48,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="JGh-7j-SFl">
- <rect key="frame" x="35" y="160" width="250" height="37"/>
+ <rect key="frame" x="35" y="142" width="250" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="PostBackground" backgroundImage="backgroundButton.png">
@@ -63,7 +63,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="3qC-jx-6RK">
- <rect key="frame" x="35" y="221" width="250" height="37"/>
+ <rect key="frame" x="35" y="198" width="250" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="PublicTimeline" backgroundImage="backgroundButton.png">
@@ -78,7 +78,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="OVU-lo-pSV">
- <rect key="frame" x="35" y="280" width="250" height="37"/>
+ <rect key="frame" x="35" y="250" width="250" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="User Timeline" backgroundImage="backgroundButton.png">
@@ -93,7 +93,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="GA8-eT-F86">
- <rect key="frame" x="35" y="337" width="250" height="37"/>
+ <rect key="frame" x="35" y="303" width="250" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="User Information" backgroundImage="backgroundButton.png">
@@ -108,7 +108,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="GRP-17-fqR">
- <rect key="frame" x="35" y="395" width="250" height="37"/>
+ <rect key="frame" x="35" y="356" width="250" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Direct Message" backgroundImage="backgroundButton.png">
@@ -122,6 +122,21 @@
<action selector="directMessageButtonAction:" destination="2" eventType="touchUpInside" id="3eF-iR-w08"/>
</connections>
</button>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="dY2-9G-6mG">
+ <rect key="frame" x="34" y="407" width="250" height="37"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+ <state key="normal" title="Retweet Message" backgroundImage="backgroundButton.png">
+ <color key="titleColor" red="0.37819006910000003" green="0.62873935010000004" blue="0.78667868590000001" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <state key="highlighted">
+ <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <connections>
+ <action selector="retweetButtonAction:" destination="2" eventType="touchUpInside" id="2ph-7t-Nzp"/>
+ </connections>
+ </button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="This message in SCTwitter Framework #ios #dev" borderStyle="roundedRect" minimumFontSize="17" id="87G-El-0gU">
<rect key="frame" x="31" y="34" width="260" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -147,28 +162,13 @@
</connections>
</viewController>
</objects>
- <point key="canvasLocation" x="-1343" y="-12"/>
+ <point key="canvasLocation" x="-1415" y="-44"/>
</scene>
</scenes>
<resources>
<image name="Default.png" width="640" height="960"/>
<image name="backgroundButton.png" width="342" height="50"/>
</resources>
- <classes>
- <class className="SCTwitterViewController" superclassName="UIViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/SCTwitterViewController.h"/>
- <relationships>
- <relationship kind="action" name="directMessageButtonAction:"/>
- <relationship kind="action" name="loginButtonAction:"/>
- <relationship kind="action" name="logoutButtonAction:"/>
- <relationship kind="action" name="postBackgroundButtonAction:"/>
- <relationship kind="action" name="publicTimelineButtonAction:"/>
- <relationship kind="action" name="userInformationButtonAction:"/>
- <relationship kind="action" name="userTimelineButtonAction:"/>
- <relationship kind="outlet" name="messageText" candidateClass="UITextField"/>
- </relationships>
- </class>
- </classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
<simulatedOrientationMetrics key="orientation"/>

0 comments on commit ca317be

Please sign in to comment.