static Order * order + (void)OrderWithTradeNO:(NSString *)tradeNO producrName:(NSString *)productName productDescrttion:(NSString *)productDescrttion price:(NSString *)price resultBlock:(void(^)(NSDictionary * ))resultBlock{
order = nil;
order = [[Order alloc] init];
order.partner = partner;
order.seller = seller;
order.tradeNO = tradeNO,//订单ID(由商家自行制定)
order.productName = productName; //商品标题
order.service = @"mobile.securitypay.pay";
order.paymentType = @"1";
order.inputCharset = @"utf-8";
order.itBPay = @"30m";
//12312312312312312312312312312
//将商品信息拼接成字符串
NSString *orderSpec = [order description];
//获取私钥并将商户信息签名,外部商户可以根据情况存放私钥和签名,只需要遵循RSA签名规范,并将签名字符串base64编码和UrlEncode
id<DataSigner> signer = CreateRSADataSigner(privateKey);
NSString *signedString = [signer signString:orderSpec];
//将签名成功字符串格式化为订单字符串,请严格按照该格式
NSString *orderString = nil;
if (signedString != nil) {
orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",
orderSpec, signedString, @"RSA"];
//网页版支付回调
[[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
if (resultBlock) {
resultBlock(resultDic);
[SVProgressHUD dismiss];
}
}];
}
NSDate * senddate=[NSDate date];
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"YYYY-MM-dd-HH:mm:ss"];
NSString * morelocationString=[dateformatter stringFromDate:senddate];
NSDictionary * dic = @{@"amount":order.amount,@"productName":order.productName,@"tradeNO":order.tradeNO,@"morelocationString":morelocationString};
[DingDanModel setDicWith:dic];//这是个单利 用于传值
}
然后在控制器里调用如下方法
[Order OrderWithTradeNO:self.orderList producrName:self.model.card_name productDescrttion:@"物美价廉" price:self.priceValue resultBlock:^(NSDictionary * dic) {
if ([dic[@"resultStatus"] isEqual:@9000]) {
PayResultController * paySuccessVC = [[PayResultController alloc] init];
paySuccessVC.resultPay = @"支付成功";
[paySuccessVC.paySuccessView setTitleColor:[UIColor colorWithRed:63/255.0 green:254/255.0 blue:131/255.0 alpha:1.0] forState:UIControlStateDisabled];
[self.navigationController pushViewController:paySuccessVC animated:YES];
}else{
PayResultController * paySuccessVC = [[PayResultController alloc] init];
paySuccessVC.resultPay = @"支付失败";
[self.navigationController pushViewController:paySuccessVC animated:YES];
}
}];
我就很好奇是哪个block造成了内存泄露
自己在Order那个类方法里把Block注释掉就不会出现内存泄露 这是什么原因求解答
排版出现了问题
位置找到就是类方法里边的那个网页版支付回调
不知道你的 block 保存在哪里,注意下有没有循环引用吧。比如按你现在的写法,持有这个 block 的人就会 retain self,如果是 viewController 持有就会造成循环引用。先用 weakSelf 代替 self 吧,别的再看一看。