他の問題を調べてみましたが、一致するものが見つからなかったため、次のようになります。
テーブル ビューにテキストを表示しようとしているので、次のコードを使用します。
// StockData is an object I created and it pulls information from Yahoo APIs based on
// a stock ticker stored in NSString *heading
NSArray* tickerValues = [heading componentsSeparatedByString:@" "];
StockData *chosenStock = [[StockData alloc] initWithContents:[tickerValues objectAtIndex:0]];
[chosenStock getData];
// Set up the cell...
NSDictionary *tempDict = [chosenStock values];
NSArray *tempArr = [tempDict allValues];
cell.textLabel.text = [tempArr objectAtIndex:indexPath.row];
return cell;
これはすべて cellForRowAtIndexPath の下にあります
selectedStock オブジェクトを解放しようとすると、次のエラーが表示されます: [CFDictionary release]: message sent to deallocated instance 0x434d3d0
NSZombieEnabled と Build and Analyze を使用して問題を検出しようとしましたが、これまでのところうまくいきませんでした。NSLog を使用してコードの断片をコメントすることさえできましたが、うまくいきませんでした。この下に StockData のコードを掲載します。リリースを行う前に何かが割り当て解除されていることがわかる限りですが、その方法はわかりません。私のコードで解放された唯一の場所は、dealloc メソッド呼び出しの下です。
StockData コードは次のとおりです。
// StockData contains all stock information pulled in through Yahoo! to be displayed
@implementation StockData
@synthesize ticker, values;
- (id) initWithContents: (NSString *)newName {
if(self = [super init]){
ticker = newName;
}
return self;
}
- (void) getData {
NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:@"http://download.finance.yahoo.com/d/quotes.csv?s=%@&f=%@&e=.csv", ticker, @"chgvj1"]];
NSError *error;
NSURLResponse *response;
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSData *stockData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if(stockData) {
NSString *tempStr = [[NSString alloc] initWithData:stockData encoding:NSASCIIStringEncoding];
NSArray *receivedValuesArr = [tempStr componentsSeparatedByString:@","];
[tempStr release];
values = [NSDictionary dictionaryWithObjects:receivedValuesArr forKeys:[@"change, high, low, volume, market" componentsSeparatedByString:@", "]];
} else {
NSLog(@"Connection failed: %@", error);
}
}
- (void)dealloc {
[ticker release];
[values release];
[super dealloc];
NSLog(@"Release took place fine");
}
@end