我正在使用objective sharpie为WePay.iOS软件开发工具包创建一个Xamarin绑定。https://github.com/wepay/wepay-ios
我已经设法构建了APIDefinition.cs和StructsAndEnums.cs文件。但是,当我创建绑定项目时,它没有成功编译。
[Export ("initWithSwipedInfo:")]
IntPtr Constructor (NSObject swipedInfo);
// -(instancetype)initWithEMVInfo:(id)emvInfo;
[Export ("initWithEMVInfo:")]
IntPtr Constructor (NSObject emvInfo);我知道我需要将NSOBject更改为正确的数据类型。然而,当我查看Objective C文件时。我真的不知道我应该使用什么数据类型。如果有人能给我指引,我将不胜感激。
Objective-C类
@interface WPPaymentInfo : NSObject
@property (nonatomic, strong, readonly) NSString *firstName;
@property (nonatomic, strong, readonly) NSString *lastName;
@property (nonatomic, strong, readonly) NSString *email;
@property (nonatomic, strong, readonly) NSString *paymentDescription;
@property (nonatomic, readonly) BOOL isVirtualTerminal;
@property (nonatomic, strong, readonly) WPAddress *billingAddress;
@property (nonatomic, strong, readonly) WPAddress *shippingAddress;
@property (nonatomic, strong, readonly) id paymentMethod;
@property (nonatomic, strong, readonly) id swiperInfo;
@property (nonatomic, strong, readonly) id manualInfo;
@property (nonatomic, strong, readonly) id emvInfo;
- (instancetype) initWithSwipedInfo:(id)swipedInfo;
- (instancetype) initWithEMVInfo:(id)emvInfo;
- (instancetype) initWithFirstName:(NSString *)firstName
lastName:(NSString *)lastName
email:(NSString *)email
billingAddress:(WPAddress *)billingAddress
shippingAddress:(WPAddress *)shippingAddress
cardNumber:(NSString *)cardNumber
cvv:(NSString *)cvv
expMonth:(NSString *)expMonth
expYear:(NSString *)expYear
virtualTerminal:(BOOL)virtualTerminal;
- (void) addEmail:(NSString *)email;
@end发布于 2016-05-19 08:49:56
swipedInfo和emvInfo在内部属于NSMutableDictionary类型。
请参阅here
- (void) handleSwipeResponse:(NSDictionary *) responseData
{
NSDictionary *info = @{@"firstName" : [WPRoamHelper firstNameFromRUAData:responseData],
@"lastName" : [WPRoamHelper lastNameFromRUAData:responseData],
@"paymentDescription": pan ? pan : @"",
@"swiperInfo" : responseData
};
WPPaymentInfo *paymentInfo = [[WPPaymentInfo alloc] initWithSwipedInfo:info];
}发布于 2016-06-03 01:58:00
@y2chaits Xamarin运行在Mono之上,它是C#。C#不允许使用相同签名的重载。因此,最好改为创建具体的数据类型。当您更改WPAddress时,您也有类似的想法。
在这种情况下,您可以将一个构造函数设置为NSObject,将第二个构造函数设置为NSDictionary (请参阅此处:https://github.com/dikoga/WePayBinding/blob/master/WePayBinding/ApiDefinition.cs)。你会做得很好的。
但是,这个绑定已经完成了。它正在构建,但它有一个问题(http://forums.xamarin.com/discussion/66446/how-to-get-more-information-when-the-app-crashes)。也许你可以花点功夫来帮助它工作,因为它已经在github上了。
https://stackoverflow.com/questions/37312003
复制相似问题