我有一個視圖控制器定義如下:目標C - 調用reloadData後的UITableView我的對象屬性爲null /零
@interface SectionController : UITableViewController {
NSMutableArray *sections;
}
- (void) LoadSections;
當LoadSection是調用它對NSURLConnection的調用加載一個URL,後者又調用
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[connection release];
[responseData release];
NSDictionary *results = [responseString JSONValue];
NSMutableArray *jSections = [results objectForKey:@"Items"];
sections = [NSMutableArray array];
for (NSArray* jSection in jSections)
{
Section* section = [Section alloc];
section.Id = [jSection objectForKey:@"Id"];
section.Description = [jSection objectForKey:@"Description"];
section.Image = [jSection objectForKey:@"Image"];
section.Parent = [jSection objectForKey:@"Parent"];
section.ProductCount = [jSection objectForKey:@"ProductCount"];
[sections addObject:section];
[section release];
}
[jSections release];
[results release];
[delegate sectionsLoaded];
[self.view reloadData];
}
的數據正確地分析,我現在有部分充滿了許多項目。
致電[self.view reloadData]強制回調委託方法的cellForRowAtIndexPath然後應在這一點上部分現在再次NIL呈現數據進入細胞但其。
有人可以指出我的錯誤嗎?我必須承認我是客觀的C新手,這可能是一個指針問題。需要做的是在調用reloadData之後保留段的值。
非常感謝。
對不起,我已編輯的帖子,包括真正的功能,我發佈節變量,雖然好點。問題仍然存在,在調用reloadData之後,節是零。這就像它重置整個viewcontroller。 – Chris 2010-10-09 17:03:07
我已更新答案以反映新代碼。我希望它可以幫助 – Bitgamma 2010-10-09 17:08:34
感謝您的答覆,但沒有任何區別。 – Chris 2010-10-09 17:25:25