当前位置:编程学习 > wap >>

如何将sinaweibo demo project 加入到 Three20UI中

想将sinaweibo demo project 加入到 Three20UI中,当用户点击thumb photo 相册的时候,一张放大的图片上加上sinaweibo图标。现在点击sinaweibo图标,可以出现 OAuth 及 XAuth 选择界面,再点击OAuth 时,App crashes.
点击 XAuth 时,出现用户名及密码登录界面,输入后,程序同样崩溃。
用的是下面的代码:


- (void)clickActionItem {} in the three20UI as follows: - (void)clickActionItem { SinaWeiBoSDKDemoViewController *sinaWeiBoSDKDemoViewController = [[[SinaWeiBoSDKDemoViewController alloc] initWithNibName:@"SinaWeiBoSDKDemoViewController" bundle:nil] autorelease]; [self.navigationController pushViewController:sinaWeiBoSDKDemoViewController animated:YES]; }


问题出在这里:[pairs addObject:[NSString stringWithFormat:@"%@=%@", key, [[dict objectForKey:key] URLEncodedString]]];

找到了URLEncodedString 的定义,而且我的项目已经引用了这个定义,可为什么还报错哪?如何修改哪? 谢谢!

It is defined in the WBUtil.m ( which is already included in the Three20UI ) as :

- (NSString *)URLEncodedString
{
return [self URLEncodedStringWithCFStringEncoding:kCFStringEncodingUTF8];
}
-----------------   WBUtil.m
#import "WBUtil.h"
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
#import "GTMBase64.h"

#pragma mark - NSData (WBEncode)

@implementation NSData (WBEncode)

- (NSString *)MD5EncodedString
{
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5([self bytes], [self length], result);

return [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]];
}

- (NSData *)HMACSHA1EncodedDataWithKey:(NSString *)key
{  
NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];
    void *buffer = malloc(CC_SHA1_DIGEST_LENGTH);
    CCHmac(kCCHmacAlgSHA1, [keyData bytes], [keyData length], [self bytes], [self length], buffer);

NSData *encodedData = [NSData dataWithBytesNoCopy:buffer length:CC_SHA1_DIGEST_LENGTH freeWhenDone:YES];
    return encodedData;
}

- (NSString *)base64EncodedString
{
return [GTMBase64 stringByEncodingData:self];
}

@end

#pragma mark - NSString (WBEncode)

@implementation NSString (WBEncode)

- (NSString *)MD5EncodedString
{
return [[self dataUsingEncoding:NSUTF8StringEncoding] MD5EncodedString];
}

- (NSData *)HMACSHA1EncodedDataWithKey:(NSString *)key
{
return [[self dataUsingEncoding:NSUTF8StringEncoding] HMACSHA1EncodedDataWithKey:key];
}

- (NSString *) base64EncodedString
{
return [[self dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString];
}

- (NSString *)URLEncodedString
{
return [self URLEncodedStringWithCFStringEncoding:kCFStringEncodingUTF8];
}

- (NSString *)URLEncodedStringWithCFStringEncoding:(CFStringEncoding)encoding
{
return [(NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[[self mutableCopy] autorelease], NULL, CFSTR("=,!$&'()*+;@?\n\"<>#\t :/"), encoding) autorelease];
}

@end

#pragma mark - NSString (WBUtil)

@implementation NSString (WBUtil)

+ (NSString *)GUIDString
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString *)string autorelease];
}

@end


得到如下 errors from the debugger console: [Session started at 2012-04-06 02:42:08 +0000.]
2012-04-06 10:42:21.656 TTNavigatorDemo[461:ef03] Current page in photo browser (1 of 10)
2012-04-06 10:42:23.635 TTNavigatorDemo[461:ef03] -[NSCFString URLEncodedString]: unrecognized selector sent to instance 0x1171e0
2012-04-06 10:42:23.638 TTNavigatorDemo[461:ef03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString URLEncodedString]: unrecognized selector sent to instance 0x1171e0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x015875a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x016db313 objc_exception_throw + 44
    2   CoreFoundation                      0x015890bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x014f8966 ___forwarding___ + 966
    4   CoreFoundation                      0x014f8522 _CF_forwarding_prep_0 + 50
    5   TTNavigatorDemo                     0x000bf4de +[WBRequest stringFromDictionary:] + 438
    6   TTNavigatorDemo                     0x000c05ad +[WBRequest serializeURL:params:httpMethod:] + 192
    7   TTNavigatorDemo                     0x000ba3db -[WBAuthorize startAuthorize] + 249
    8   TTNavigatorDemo                     0x000bd238 -[WBEngine logIn] + 592
    9   TTNavigatorDemo                     0x000c770d -[SinaWeiBoSDKDemoViewController onLogInOAuthButtonPressed] + 53
    10  UIKit                               0x004ab4fd -[UIApplication sendAction:to:from:forEvent:] + 119
    11  UIKit                               0x0053b799 -[UIControl sendAction:to:forEvent:] + 67
    12  UIKit                               0x0053dc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    13  UIKit                               0x0053c7d8 -[UIControl touchesEnded:withEvent:] + 458
    14  UIKit                               0x004cfded -[UIWindow _sendTouchesForEvent:] + 567
    15  UIKit                               0x004b0c37 -[UIApplication sendEvent:] + 447
    16  UIKit                               0x004b5f2e _UIApplicationHandleEvent + 7576
    17  GraphicsServices                    0x01e53992 PurpleEventCallback + 1550
    18  CoreFoundation                      0x01568944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    19  CoreFoundation                      0x014c8cf7 __CFRunLoopDoSource1 + 215
    20  CoreFoundation                      0x014c5f83 __CFRunLoopRun + 979
    21  CoreFoundation                      0x014c5840 CFRunLoopRunSpecific + 208
    22  CoreFoundation                      0x014c5761 CFRunLoopRunInMode + 97
    23  GraphicsServices                    0x01e521c4 GSEventRunModal + 217
    24  GraphicsServices                    0x01e52289 GSEventRun + 115
    25  UIKit                               0x004b9c93 UIApplicationMain + 1160
    26  TTNavigatorDemo                     0x000028de main + 104
    27  TTNavigatorDemo                     0x0000286d start + 53
)
terminate called throwing an exception
--------------------编程问答-------------------- 准备将sinaweibo demo project 做成一个伪框架, 请问谁曾经将sinaweibo demo project 做成过一个伪框架? --------------------编程问答--------------------
补充:移动开发 ,  iPhone
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,