最近要做一個(gè)支付的SDK給第三方APP調(diào)用,靜態(tài)庫(kù)啥的網(wǎng)上已經(jīng)有好多了尚卫,就不復(fù)述啦归榕!主要說一下里面的代理如何實(shí)現(xiàn),主要是怕自己下次又忘記了??
關(guān)鍵是加上一個(gè)單例就行了吱涉,其他的不用改變刹泄。外里。。
.h文件
#import@interface CmpayiPosLib : NSObject
+ (instancetype)sharedInstanceiPosLib;
- (void)payOrderTest;
@end
.m文件
@interface CmpayiPosLib ()<UIAlertViewDelegate>
@end
@implementation CmpayiPosLib
#pragma mark - public methods
+ (instancetype)sharedInstanceiPosLib{
static CmpayiPosLib *cmpiPoslib;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
cmpiPoslib = [[CmpayiPosLib alloc] init];
});
return cmpiPoslib;
}
- (void)payOrderTest{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"檢測(cè)到您還未安裝和包支付或者版本過低特石,請(qǐng)先下載安裝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"clickButtonAtIndex:%ld",buttonIndex);
}
使用CmpayiPosLib這個(gè)類:
[[CmpayiPosLib sharedInstanceiPosLib] payOrderTest];