我具有被從XML文件加載內部的數據結構對象時奇怪的輸出中的「沒有完成加載」委託的方法。試圖訪問數據
如果我使用的數據對象「printData」方法從委託的加載方法裏面顯示的所有信息。我可以多次這樣做。
不過,我有它運行在委託的第二種方法的按鈕,這一切都運行我的數據對象的printData方法,但我得到的是存在或是一些隨機屬性的文本。
例如「UIDeviceFamily」或「ar.lproj」等...
一旦這已打印崩潰該應用具有「EXC_BAD_ACCESS」錯誤。
我記得有一個目錄可以找到這個錯誤的更多細節,但我不記得它是哪一個。
感謝您提供的任何幫助。
對不起,這是在應用程序中重要的代碼...
這是填充數據的代碼。
-(id)initMapFromXMLData:(NSData *)xmlData
{
if (self = [super init])
{
MapXMLParser *parser = [[MapXMLParser alloc] initWithData:xmlData];
[parser setDelegate:parser];
[parser parse];
statementPairs = [NSDictionary dictionaryWithDictionary:parser.statementPairs];
prefPairs = [NSDictionary dictionaryWithDictionary:parser.prefPairs];
clusters = [NSDictionary dictionaryWithDictionary:parser.clusters];
/*
statementPairs = parser.statementPairs;
prefPairs = parser.prefPairs;
clusters = parser.clusters;
[parser release];*/
}
return self;
}
這就被從委託運行...
NSData *xmlData;
xmlData = [[NSData alloc] initWithContentsOfFile:@"/Users/oliver/Documents/XCode stuff/Saviio/Saviio 2/Saviio/Classes/Statements"];
myMap = [[Map alloc] initMapFromXMLData:xmlData];
然後在相同的委託方法我展示它...
[myMap printClusters];
...它運行。 ..
-(void)printClusters
{
NSLog(@"Printing Clusters for %@", self);
for (int i = 1; i <= [clusters count]; i++)
{
Cluster *tempCluster;
tempCluster = [clusters objectForKey:[NSString stringWithFormat:@"%d", i]];
NSLog(@"Cluster %@", tempCluster.name);
for (int j = 0 ; j < [tempCluster.fgids count]; j++)
{
Preference *tempPref;
tempPref = [prefPairs objectForKey:[[tempCluster.fgids objectAtIndex:j] stringValue]];
NSLog(@"Pref ---> %@/%@", tempPref.left, tempPref.right);
for (int k = 0 ; k < [tempPref.qids count]; k++)
{
Statement *tempStat;
tempStat = [statementPairs objectForKey:[[tempPref.qids objectAtIndex:k] stringValue]];
NSLog(@"Stat -------> %@ - %@", tempStat.left, tempStat.right);
}
}
}
NSLog(@"END");
}
這一切工作正常。
但是,當我然後運行相同的方法[myMap printClusters]從一個按鈕在代理中運行的方法,然後它打印第一行...「打印羣集for」。
然後怪行,然後崩潰。
如果您可以發佈一些代碼,它會更好。內存管理問題,像往常一樣 – vodkhang 2010-08-15 15:35:39
增加了一些代碼。 我希望它是有道理的。代碼遍歷集羣,然後遍歷集羣的每個首選項,然後遍歷每個首選項。 – Fogmeister 2010-08-15 15:56:22