Permalink
Browse files

将认证的delegate移到了app delegate中

由于直接保存对象出现问题,现在所有的认证的delegate都会根据传入的@selector调用app delegate中的方法。
  • Loading branch information...
1 parent c98bfb7 commit faa0f11cda02e5af702a1e1e7f021c3a5a5c0cec @qdvictory committed Aug 22, 2011
View
Binary file not shown.
Binary file not shown.
@@ -19,7 +19,7 @@
SEL _failSEL;
}
+ (WBShareKit *)mainShare;
-- (void)setDelegate:(id)delegate;
+//- (void)setDelegate:(id)delegate;
- (void)handleOpenURL:(NSURL *)url;
#pragma mark sina
@@ -33,12 +33,12 @@ - (NSString *)replaceURLPlus:(NSString *)_str
return [_str stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"];
}
-#pragma mark setDelegate
-- (void)setDelegate:(id)delegate
-{
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- [NSKeyedArchiver archiveRootObject:delegate toFile:path];
-}
+//#pragma mark setDelegate
+//- (void)setDelegate:(id)delegate
+//{
+// NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
+// [NSKeyedArchiver archiveRootObject:delegate toFile:path];
+//}
#pragma mark 获得时间戳
- (NSString *)_generateTimestamp
@@ -375,9 +375,8 @@ - (void)startSinaAccessWithVerifier:(NSString *)_ver
- (void)sinaAccessTokenTicket:(OAServiceTicket *)ticket failedWithError:(NSError *)error {
NSLog(@"sina 获取access token失败 错误:%@",error);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_ESel"]) withObject:error];
}
@@ -391,8 +390,8 @@ - (void)sinaAccessTokenTicket:(OAServiceTicket *)ticket finishedWithData:(NSMuta
NSLog(@"获取access token:%@",responseBody);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
+// NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_SSel"]) withObject:data];
// [responseBody release];
@@ -626,9 +625,8 @@ - (void)startDoubanAccess
- (void)doubanAccessTokenTicket:(OAServiceTicket *)ticket failedWithError:(NSError *)error {
NSLog(@"douban 获取access token失败 错误:%@",error);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_ESel"]) withObject:error];
}
@@ -642,8 +640,8 @@ - (void)doubanAccessTokenTicket:(OAServiceTicket *)ticket finishedWithData:(NSMu
NSLog(@"获取access token:%@",responseBody);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
+// NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_SSel"]) withObject:data];
// [responseBody release];
@@ -784,9 +782,8 @@ - (void)startTxAccessWithVerifier:(NSString *)_ver
- (void)txAccessTokenTicket:(OAServiceTicket *)ticket failedWithError:(NSError *)error {
NSLog(@"tx 获取access token失败 错误:%@",error);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_ESel"]) withObject:error];
}
@@ -800,8 +797,8 @@ - (void)txAccessTokenTicket:(OAServiceTicket *)ticket finishedWithData:(NSMutabl
NSLog(@"获取access token:%@",responseBody);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
+// NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_SSel"]) withObject:data];
// [responseBody release];
@@ -1036,9 +1033,8 @@ - (void)startTwitterAccess
- (void)twitterAccessTokenTicket:(OAServiceTicket *)ticket failedWithError:(NSError *)error {
NSLog(@"twitter 获取access token失败 错误:%@",error);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_ESel"]) withObject:error];
}
@@ -1052,8 +1048,8 @@ - (void)twitterAccessTokenTicket:(OAServiceTicket *)ticket finishedWithData:(NSM
NSLog(@"获取access token:%@",responseBody);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
+// NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_SSel"]) withObject:data];
// [responseBody release];
}
@@ -1158,9 +1154,8 @@ - (void)startWyAccess
- (void)wyAccessTokenTicket:(OAServiceTicket *)ticket failedWithError:(NSError *)error {
NSLog(@"wy 获取access token失败 错误:%@",error);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_ESel"]) withObject:error];
}
@@ -1174,8 +1169,8 @@ - (void)wyAccessTokenTicket:(OAServiceTicket *)ticket finishedWithData:(NSMutabl
NSLog(@"获取access token:%@",responseBody);
- NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"WBShareKit.delegate"];
- id delegate = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
+// NSUserDefaults *info = [NSUserDefaults standardUserDefaults];
+ id delegate = [[UIApplication sharedApplication] delegate];
[delegate performSelector:NSSelectorFromString([info valueForKey:@"WBShareKit_SSel"]) withObject:data];
// [responseBody release];
@@ -81,4 +81,57 @@ - (void)dealloc
[super dealloc];
}
+#pragma mark sina delegate
+- (void)sinaSuccess:(NSData *)_data
+{
+ NSLog(@"sina ok:%@",_data);
+}
+
+- (void)sinaError:(NSError *)_error
+{
+ NSLog(@"sina error:%@",_error);
+}
+#pragma mark douban delegate
+- (void)doubanSuccess:(NSData *)_data
+{
+ NSLog(@"douban ok:%@",_data);
+}
+
+- (void)doubanError:(NSError *)_error
+{
+ NSLog(@"douban error:%@",_error);
+}
+#pragma mark tx delegate
+- (void)txSuccess:(NSData *)_data
+{
+ NSLog(@"tx ok:%@",_data);
+}
+
+- (void)txError:(NSError *)_error
+{
+ NSLog(@"tx error:%@",_error);
+}
+
+#pragma mark twitter delegate
+- (void)twitterSuccess:(NSData *)_data
+{
+ NSLog(@"twitter ok:%@",_data);
+}
+
+- (void)twitterError:(NSError *)_error
+{
+ NSLog(@"twitter error:%@",_error);
+}
+
+#pragma mark 163 delegate
+- (void)wySuccess:(NSData *)_data
+{
+ NSLog(@"wy ok:%@",_data);
+}
+
+- (void)wyError:(NSError *)_error
+{
+ NSLog(@"wy error:%@",_error);
+}
+
@end
@@ -42,7 +42,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
}
- (IBAction)StartSina:(id)sender {
- [[WBShareKit mainShare] setDelegate:self];
+// [[WBShareKit mainShare] setDelegate:self];
[[WBShareKit mainShare] startSinaOauthWithSelector:@selector(sinaSuccess:) withFailedSelector:@selector(sinaError:)];
}
@@ -56,7 +56,7 @@ - (IBAction)StartSinaPhotoWeibo:(id)sender {
}
- (IBAction)StartDouban:(id)sender {
- [[WBShareKit mainShare] setDelegate:self];
+// [[WBShareKit mainShare] setDelegate:self];
[[WBShareKit mainShare] startDoubanOauthWithSelector:@selector(doubanSuccess:) withFailedSelector:@selector(doubanError:)];
}
@@ -65,7 +65,7 @@ - (IBAction)StartSendDoubanShuo:(id)sender {
}
- (IBAction)StartTX:(id)sender {
- [[WBShareKit mainShare] setDelegate:self];
+// [[WBShareKit mainShare] setDelegate:self];
[[WBShareKit mainShare] startTxOauthWithSelector:@selector(txSuccess:) withFailedSelector:@selector(txError:)];
}
@@ -78,7 +78,7 @@ - (IBAction)StartTXPhotoWeibo:(id)sender {
}
- (IBAction)StartTwitter:(id)sender {
- [[WBShareKit mainShare] setDelegate:self];
+// [[WBShareKit mainShare] setDelegate:self];
[[WBShareKit mainShare] startTwitterOauthWithSelector:@selector(twitterSuccess:) withFailedSelector:@selector(twitterError:)];
}
@@ -87,7 +87,7 @@ - (IBAction)StartSendTwitter:(id)sender {
}
- (IBAction)StartWy:(id)sender {
- [[WBShareKit mainShare] setDelegate:self];
+// [[WBShareKit mainShare] setDelegate:self];
[[WBShareKit mainShare] startWyOauthWithSelector:@selector(wySuccess:) withFailedSelector:@selector(wyError:)];
}
@@ -100,16 +100,7 @@ - (IBAction)StartSendWyPhotoWeibo:(id)sender {
}
-#pragma mark sina delegate
-- (void)sinaSuccess:(NSData *)_data
-{
- NSLog(@"sina ok:%@",_data);
-}
-
-- (void)sinaError:(NSError *)_error
-{
- NSLog(@"sina error:%@",_error);
-}
+#pragma mark sina&163&tx&twitter delegate
- (void)sendRecordTicket:(OAServiceTicket *)ticket finishedWithData:(NSMutableData *)data
{
@@ -126,15 +117,6 @@ - (void)sendRecordTicket:(OAServiceTicket *)ticket failedWithError:(NSError *)er
}
#pragma mark douban delegate
-- (void)doubanSuccess:(NSData *)_data
-{
- NSLog(@"douban ok:%@",_data);
-}
-
-- (void)doubanError:(NSError *)_error
-{
- NSLog(@"douban error:%@",_error);
-}
- (void)sendDoubanShuoTicket:(OAServiceTicket *)ticket finishedWithData:(NSMutableData *)data
{
@@ -150,37 +132,5 @@ - (void)sendDoubanShuoTicket:(OAServiceTicket *)ticket failedWithError:(NSError
}
-#pragma mark tx delegate
-- (void)txSuccess:(NSData *)_data
-{
- NSLog(@"tx ok:%@",_data);
-}
-
-- (void)txError:(NSError *)_error
-{
- NSLog(@"tx error:%@",_error);
-}
-
-#pragma mark twitter delegate
-- (void)twitterSuccess:(NSData *)_data
-{
- NSLog(@"twitter ok:%@",_data);
-}
-
-- (void)twitterError:(NSError *)_error
-{
- NSLog(@"twitter error:%@",_error);
-}
-
-#pragma mark 163 delegate
-- (void)wySuccess:(NSData *)_data
-{
- NSLog(@"wy ok:%@",_data);
-}
-
-- (void)wyError:(NSError *)_error
-{
- NSLog(@"wy error:%@",_error);
-}
@end

0 comments on commit faa0f11

Please sign in to comment.