2016-05-19 14 views
0

私は目的のシャーピーを使用してWePay.iOS SDKのXamarinバインディングを作成しています。 https://github.com/wepay/wepay-iosWePayのXamarin.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 

答えて

0

swipedInfoとemvInfoは、内部タイプNSMutableDictionaryのです。

hereを参照してください:y2chaits @

- (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]; 
} 
+0

しかし、どのように同じ数のパラメータで同じデータ型を持つことができますか。それはビルドエラーの権利を与えるだろうか? –

+0

@LibinJoseph Xamarinの仕組みはわかりませんが、iOS側ではメソッドのシグネチャが異なります。 – y2chaits

0

はXamarinは、モノの上で動作し、それは、C#です。 C#では、同じ署名で過負荷を許可していません。したがって、代わりに具体的なデータ型を作成するとよいでしょう。 WPAddressを変更したときも同様の考えがありました。

この場合、1つのコンストラクタをNSObjectに、2番目のコンストラクタをNSDictionaryに設定できます(ここではhttps://github.com/dikoga/WePayBinding/blob/master/WePayBinding/ApiDefinition.cs参照)。そして、あなたは良いことになるでしょう。

ただし、このバインドは既に行われています。それは建物ですが、それには1つの問題(http://forums.xamarin.com/discussion/66446/how-to-get-more-information-when-the-app-crashes)があります。たぶんあなたはすでにgithub上にあるので、それが動作するようにいくつかの努力をすることができます。

関連する問題