1

私のアプリが今日公開されたばかりなので、これは「ちょっと」緊急です。

私のアプリはエミュレーターで正常に動作します。携帯電話、iPad、その他のiPhoneにコピーすると正常に動作します。私たちはアプリから一体をテストしました。アプリストアに送信したところ、承認されて公開されましたが、ダウンロードしたアプリストアアプリでのみエラーが発生します。

基本的に、NSDecimalと数値フォーマッターを使用して請求書のバランスを取り直しています。エミュレーターと電話では、コードをステップスルーするとすべてうまくいきます。しかし、appstoreバンドルはウィッグアウトします。足し算と引き算をしているデータが初期化されていないようです。

誰かがこのようなものを見たことがありますか?

この投稿は完全に曖昧ですが、エミュレーターのコードが正常に機能する場合にデバッグを開始する場所を見つけようとしています。

--UPDATE--コードの追加

 -(void)balanceBill:(UITextField*)textField 
 {
//save the text field data
int row                         = [textField tag] - 900;
NSString *enteredSplitAmount    = [formatter stringWithNoCurrency:[textField text]];
[theGuestTotals replaceObjectAtIndex:row withObject:enteredSplitAmount];

//Get data object
BillDataObject* data    = [self theAppDataObject];

int changedSplitBy  = 0;
UITableViewCell *cell;
UITextField     *cellTextField;

double          adjustedBill = 0.0;
NSString        *guestAmountFromArray;
//NSString        *guestAmountAdjusted;

//Figure out how many guests did NOT have their bill changed & get new bill total
for (NSUInteger i=0; i < [theGuestTotals count]; i++)
{
    guestAmountFromArray        = [theGuestTotals objectAtIndex:i];
    if ([guestAmountFromArray   isEqualToString:data.splitByAmountChanged]) 
    {
        changedSplitBy++;
    }    
    //Adding ALL guest amounts to get a NEW Bill Total
    adjustedBill += [guestAmountFromArray doubleValue];
}

if (changedSplitBy == 0)
    changedSplitBy = 1;


//Convert newBill to decimal
NSDecimalNumber *adjustedBillTotal = [[NSDecimalNumber alloc] initWithDouble:adjustedBill];
NSDecimalNumber *originalBillTotal = [[NSDecimalNumber alloc] initWithString:data.totalBill];    

NSDecimalNumber *splitBy = [[NSDecimalNumber alloc] initWithInt:changedSplitBy];
NSDecimalNumber *updatedGuestAmount;

//Figure out the the difference is between the new amount and the old amount
NSDecimalNumber *adjustedBillTotalDifference = [originalBillTotal decimalNumberBySubtracting:adjustedBillTotal];

//figure out the difference each guest who did not have their bill changed difference
NSDecimalNumber *guestSplitAmountDifference = [adjustedBillTotalDifference decimalNumberByDividingBy:splitBy];

//loop through array of guest totals to see if a guest total if different from the original split amout
for (NSUInteger i=0; i < [theGuestTotals count]; i++)
{
    guestAmountFromArray = [theGuestTotals objectAtIndex:i];

    if ([guestAmountFromArray isEqualToString:data.splitByAmountChanged]) 
    {
        NSDecimalNumber *guestAmount = [[NSDecimalNumber alloc] initWithString:[theGuestTotals objectAtIndex:i]];

        NSIndexPath *indexPath  = [NSIndexPath indexPathForRow:i inSection:0];
        cell                    = [tableView cellForRowAtIndexPath:indexPath];
        cellTextField           = (UITextField*)[cell viewWithTag:i+900];

        //add the split amount to the guest amount
        updatedGuestAmount = [guestAmount decimalNumberByAdding:guestSplitAmountDifference];
        //update the textfield with UPDATED amount
        cellTextField.text      = [formatter stringWithNumberStyle:NSNumberFormatterCurrencyStyle numberToFormat:updatedGuestAmount];            
        //replace the guest amount in the array with the UPDATED amount
        [theGuestTotals         replaceObjectAtIndex:i withObject:[formatter stringWithNumberStyle:NSNumberFormatterDecimalStyle numberToFormat:updatedGuestAmount]];
    } else {
        //Not equal so just update the amount from what it was...
        //this might not be needed but I need to format if it is...
        cellTextField.text      = [formatter stringWithNumberStyle:NSNumberFormatterCurrencyStyle numberToFormat:            [NSDecimalNumber decimalNumberWithString:guestAmountFromArray]];
    }
}

//Now all guests who were not edited GOT updated now save that update for the next time this function is run
data.splitByAmountChanged = [formatter stringWithNumberStyle:NSNumberFormatterDecimalStyle numberToFormat:updatedGuestAmount];

//Clear out adjustedBill to get NEW totals after we updated each guest in the loop above
adjustedBill = 0;
//Lets see if we are over or under and do the 'REDISTRIBUTE'
for (NSUInteger i=0; i < [theGuestTotals count]; i++)
{
    adjustedBill += [[theGuestTotals objectAtIndex:i] doubleValue];
}

adjustedBillTotal = [[NSDecimalNumber alloc] initWithDouble:adjustedBill];

if ([originalBillTotal compare:adjustedBillTotal] == NSOrderedAscending) 
{  
    [warningImage setHidden:NO];
    NSDecimalNumber *overage = [adjustedBillTotal decimalNumberBySubtracting:originalBillTotal];

    [overUnderLabel setText:[NSString stringWithFormat:@"%@ over",[formatter stringWithNumberStyle:NSNumberFormatterCurrencyStyle numberToFormat:overage]]];

   // [self disableDone];
    [self enableRedistribute];
} 
else if ([originalBillTotal compare:adjustedBillTotal] == NSOrderedDescending) 
{
    [warningImage setHidden:NO];        
    NSDecimalNumber *underage = [originalBillTotal decimalNumberBySubtracting:adjustedBillTotal]; 

    [overUnderLabel setText:[NSString stringWithFormat:@"%@ under",[formatter stringWithNumberStyle:NSNumberFormatterCurrencyStyle numberToFormat:underage]]];

   // [self disableDone];
    [self enableRedistribute];
} 
else 
{
    [warningImage setHidden:YES];        
    overUnderLabel.text = @"";
    //[self enableDone];
    [self disableRedistribute];
}

}

4

2 に答える 2

0

問題は、データストレージにUITableViewCellsを使用しようとしていることだと思います。データをセルにプッシュするのではなく、UITableViewがcellForRowAtIndexPathメソッドを呼び出すのを待ちます。

UITableViewは、画面全体に表示されるのに十分なセルのみを保持します。スクロールして見えなくなるとすぐに解放されます。ループがcellForRowAtIndexPathを使用して再度取得しようとすると、新しいセルが割り当てられます。ループはそれを初期化するかもしれませんが、UITableオブジェクトによって保存または使用されることはありません。

于 2012-02-29T02:24:43.113 に答える
0

私のメソッドに2つの変数があるデッドストアの問題がありました。後で設定しましたが、削除してアプリを再送信しました。問題は解決しました。

ヒントをありがとう。

于 2012-03-05T19:04:33.477 に答える