-2
オブジェクトをメソッドに渡すときに、オブジェクトの値がnullに変更されるアプリケーションがあります。私はブログでこれを見つけることができませんでした。私が何をすべきかを提案してください。私はそれが参照や価値によるもののようなものだとは思っていますが、あまり知らないのです。メソッドがオブジェクトに渡された後に、オブジェクトが割り当て解除される
NSNumber* resultSelectedWeekValue;
と財産
@property (nonatomic, retain) NSNumber* resultSelectedWeekValue;
などの* .hファイル内の変数宣言とimplimentaion
@synthesize resultSelectedWeekValue = _resultSelectedWeekValue;
にこれは、1つのポップオーバーから値を取得する方法を委任しています
// Show discription of Selected week
-(void) getSelectedWeekDelegateMethod:(NSString*) getSelectedWeek {
_resultSelectedWeekValue = [_dbObject getSelectedWeekValue:getSelectedWeek];
NSLog(@"This is _tempOzs %@ ", _resultSelectedWeekValue);
if ([_productAttributePopover isPopoverVisible]) {
[_productAttributePopover dismissPopoverAnimated:YES];
}
}
NSLog(@"This is _resultSelectedWeekValue %@ and class %@", _resultSelectedWeekValue, [_resultSelectedWeekValue class]); // This say the object is deallocate? this is the code below
if ((_resultSelectedWeekValue != nil) && (_tempGranularProduct != nil || _tempLiquidProduct != nil) && (_tempLbs != nil || _tempOzs != nil)) {
if ([_tempLbs intValue] != 0) {
NSDate* _createdDate = [NSDate date];
//Create the dateformatter object
NSDateFormatter* _formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
[_formatter setDateFormat:@"yyyy-MM-dd"];
//Get the string date
NSString* _formatDate = [_formatter stringFromDate:_createdDate];
NSNumber* _getNumBags = [self calculateGranularBags];
NSNumber* _getProductID = [[_dbObject getAppliedProductWeightAttribute:_tempGranularProduct] objectForKey:@"productid"];
NSNumber* _totalInvestment = [[NSNumber alloc] initWithInt:0];
NSLog(@"This is _tempScenarioId %@ and class %@", _tempScenarioId, [_tempScenarioId class]);
NSLog(@"This is _resultSelectedWeekValue %@ and class %@", _resultSelectedWeekValue, [_resultSelectedWeekValue class]);
NSLog(@"This is _getProductID %@ and class %@", _getProductID, [_getProductID class]);
NSLog(@"This is _tempLbs %@ and class %@", _tempLbs, [_tempLbs class]);
NSLog(@"This is _getNumBags %@ and class %@", _getNumBags, [_getNumBags class]);
NSLog(@"This is _totalInvestment %@ and class %@", _totalInvestment, [_totalInvestment class]);
NSLog(@"This is _tempCarryover %@ and class %@", _tempCarryover, [_tempCarryover class]);
NSMutableDictionary* _scenarioProductAttribute = [NSMutableDictionary dictionaryWithObjectsAndKeys:
_tempScenarioId, @"scenarioid",
_resultSelectedWeekValue, @"weekvalue",
_getProductID, @"productid",
_tempLbs, @"lbper1000ft",
_getNumBags, @"numberofbags",
_totalInvestment, @"totalinvestment",
_tempCarryover, @"carry_n",
_formatDate, @"date",
nil];
[_totalInvestment release];
_tempScenarioId = [_dbObject insertScenarioProductAttribute:_scenarioProductAttribute andScenarioId:_tempScenarioId andProductId:_getProductID andSelectedWeekValue:_resultSelectedWeekValue];
// Check Point
[TestFlight passCheckpoint:@"INSERT_GRANULAR_RECORD"];
}
if ([_tempOzs intValue] != 0) {
NSDate* _createdDate = [NSDate date];
//Create the dateformatter object
NSDateFormatter* _formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
[_formatter setDateFormat:@"yyyy-MM-dd"];
//Get the string date
NSString* _formatDate = [_formatter stringFromDate:_createdDate];
NSNumber* _getGallons = [self calculateLiquidGallons];
NSNumber* _getProductID = [[_dbObject getAppliedProductWeightAttribute:_tempLiquidProduct] objectForKey:@"productid"];
NSNumber* _totalInvestment = [[NSNumber alloc] initWithInt:0];
NSLog(@"This is _tempScenarioId %@ and class %@", _tempScenarioId, [_tempScenarioId class]);
NSLog(@"This is _resultSelectedWeekValue %@ and class %@", _resultSelectedWeekValue, [_resultSelectedWeekValue class]); // This say the object is deallocate?
NSLog(@"This is _getProductID %@ and class %@", _getProductID, [_getProductID class]);
NSLog(@"This is _tempOzs %@ and class %@", _tempOzs, [_tempOzs class]);
NSLog(@"This is _getGallons %@ and class %@", _getGallons, [_getGallons class]);
NSLog(@"This is _totalInvestment %@ and class %@", _totalInvestment, [_totalInvestment class]);
NSLog(@"This is _tempCarryover %@ and class %@", _tempCarryover, [_tempCarryover class]);
NSMutableDictionary* _scenarioProductAttribute = [NSMutableDictionary dictionaryWithObjectsAndKeys:
_tempScenarioId, @"scenarioid",
_resultSelectedWeekValue, @"weekvalue",
_getProductID, @"productid",
_tempOzs, @"ounces",
_getGallons, @"gallons",
_totalInvestment, @"totalinvestment",
_tempCarryover, @"carry_n",
_formatDate, @"date",
nil];
[_totalInvestment release];
_tempScenarioId = [_dbObject insertScenarioProductAttribute:_scenarioProductAttribute andScenarioId:_tempScenarioId andProductId:_getProductID andSelectedWeekValue:_resultSelectedWeekValue];
多くのコードを提供していますが、問題の解決に役立つものはありません。 '_resultSelectedWeekValue'がどのように設定されているか知る必要があります。おそらく、自動リリースされたオブジェクトに設定されている可能性があります。 – Joe
_gosh _that _code _is _hard _to _read。 _why _are _are _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ – jrturton
_he _read _somewhere _that _you _can _do _for _all _members _of _a _class _and _taken _it _too _far _I _guess – deanWombourne