我正在将PayPal-iOS-SDK pod与RubyMotion集成,但是在运行这行代码时应用程序崩溃了:
subtotal = PayPalItem.totalPriceForItems(items)
我正在尝试将此Objective-C代码移植到RubyMotion
PayPalItem *item1 = [PayPalItem itemWithName:@"Blue Jeans"
withQuantity:2
withPrice:[NSDecimalNumber decimalNumberWithString:@"34.89"]
withCurrency:@"USD"
withSku:@"Hip-00010"];
PayPalItem *item2 = [PayPalItem itemWithName:@"Red Jeans"
withQuantity:1
withPrice:[NSDecimalNumber decimalNumberWithString:@"0.00"]
withCurrency:@"USD"
withSku:@"Hip-00020"];
PayPalItem *item3 = [PayPalItem itemWithName:@"Black Jeans"
withQuantity:1
withPrice:[NSDecimalNumber decimalNumberWithString:@"29.99"]
withCurrency:@"USD"
withSku:@"Hip-00030"];
NSArray *items = @[item1, item2, item3];
NSDecimalNumber *subtotal = [PayPalItem totalPriceForItems:items];
这是我的RubyMotion代码:
item1 = PayPalItem.itemWithName('Blue Jeans',
withQuantity: 2,
withPrice: NSDecimalNumber.decimalNumberWithString('34.89'),
withCurrency: 'USD',
withSku: 'Hip-00010')
item2 = PayPalItem.itemWithName('Red Jeans',
withQuantity: 1,
withPrice: NSDecimalNumber.decimalNumberWithString('0.00'),
withCurrency: 'USD',
withSku: 'Hip-00020')
item3 = PayPalItem.itemWithName('Black Jeans',
withQuantity: 1,
withPrice: NSDecimalNumber.decimalNumberWithString('29.99'),
withCurrency: 'USD',
withSku: 'Hip-00030')
items = [item1, item2, item3]
subtotal = PayPalItem.totalPriceForItems(items)
但是,当应用程序到达此行时,应用程序崩溃了:
subtotal = PayPalItem.totalPriceForItems(items)
这是我得到的错误:
2014-05-08 19:26:56.492 B4TS [8230:70b] - [__ NSCFNumber decimalNumberByMultiplyingBy:]:无法识别的选择器发送到实例0xcae0550 2014-05-08 19:26:57.808 B4TS [8230:70b] * 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [__ NSCFNumber decimalNumberByMultiplyingBy:]:无法识别的选择器发送到实例0xcae0550 “
非常感谢任何帮助。