0
我有這段代碼與我的應用程序內購買一個SKProductRequest
:以下代碼是否會在舊設備上產生崩潰?
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:...
request.delegate = self;
[request start];
[request release];
一個越來越上iPod4崩潰,我想這可能是由這一點,但是,所有其他設備能夠運行此代碼確定。如果請求在裝載時被保存在一個屬性中,那可能是問題嗎?我會認爲[請求開始],該請求將保留在其他地方。
這裏是崩潰日誌:
Last Exception Backtrace:
0 CoreFoundation 0x3275229e __exceptionPreprocess + 158
1 libobjc.A.dylib 0x3a3c597a objc_exception_throw + 26
2 CoreFoundation 0x3269ce88 -[__NSArrayI objectAtIndex:] + 160
3 AppsHappens Lite 0x000e43ac 0xd8000 + 50092
4 StoreKit 0x3450c22e __34-[SKProductsRequest _handleReply:]_block_invoke_0 + 378
5 libdispatch.dylib 0x3a7dd11a _dispatch_call_block_and_release + 6
6 libdispatch.dylib 0x3a7dc4b2 _dispatch_client_callout + 18
7 libdispatch.dylib 0x3a7dddc6 _dispatch_main_queue_callback_4CF$VARIANT$up + 222
8 CoreFoundation 0x32725f36 __CFRunLoopRun + 1286
9 CoreFoundation 0x32698eb8 CFRunLoopRunSpecific + 352
10 CoreFoundation 0x32698d44 CFRunLoopRunInMode + 100
11 GraphicsServices 0x362492e6 GSEventRunModal + 70
12 UIKit 0x345ae2fc UIApplicationMain + 1116
13 AppsHappens Lite 0x000e3a8e 0xd8000 + 47758
14 AppsHappens Lite 0x000dadb4 0xd8000 + 11700
更新:很多人以下的是說,它是一個數組越界錯誤的,我認爲他們是對的。奇怪的是,它似乎產品要求成功回來了,它叫做[self loadFullVersionPrice]
,它簡單地提取我的一個產品的價格。當它試圖從products
數組中檢索完整版產品時,我認爲這是它崩潰的時候。應用商店是否有可能只返回我的一些產品,而不是所有產品?或者iPod4有問題?
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
self.products = response.products;
if (self.products)
{
[self loadFullVersionPrice];
}
}
- (void) loadFullVersionPrice
{
SKProduct *product = [[self.products objectAtIndex:[self.products count]-1] retain];
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
self.fullVersionPrice = [numberFormatter stringFromNumber:product.price];
[numberFormatter release];
[product release];
}
此外,有問題的iPod Touch 4也被監禁。
什麼是「自我」? SKProductRequest不保留它的委託,所以如果「self」沒有保留在某處,那麼SKProductRequest可能會回調到一個dealloc對象並崩潰。嘗試從用戶那裏獲取崩潰日誌,或查看iTunes Connect崩潰報告並查看是否追蹤發生崩潰的位置。 –
不要猜測,自己保存以確保。另外,從你的用戶那裏獲取崩潰日誌。 – Wain
這可能是一個時間相關的錯誤,這表現在較慢的設備上。這也可能是操作系統的差異。對於上面的代碼,似乎你應該在調用'-start'和'-release'之前調用'-stop',否? – nielsbot