iphone中的Tableview重新加载问题?
这是我的代码,我重新加载了tableview;m获取exe错误访问错误iphone中的Tableview重新加载问题?,iphone,objective-c,xcode,uitableview,Iphone,Objective C,Xcode,Uitableview,这是我的代码,我重新加载了tableview;m获取exe错误访问错误 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"the count is %i",recievedSchool.count); return [recievedSchool count]; } - (UITableVie
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"the count is %i",recievedSchool.count);
return [recievedSchool count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// recievedSchool=[[recievedSchool alloc]initWithArray:newschool copyItems:YES];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// NSLog(@"recieved school data are>>>>%@",newschool);
cell.textLabel.text=[recievedSchool objectAtIndex:indexPath.row];
// [newschool release];
return cell;
}
-(void)searchRequest {
NSString *post =
[[NSString alloc] initWithFormat:@"keyword=%@",searchBar.text];
// NSString *urlString = [NSString stringWithFormat:@"http://3cs.co.in/mobileApps/home.php"];
NSURL *url = [NSURL URLWithString:@"http://3cs.co.in/mobileApps/search.php"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
NSString *msgLength = [NSString stringWithFormat:@"%d", [post length]];
[theRequest setHTTPMethod:@"POST"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
NSData * data=[post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
[theRequest setHTTPBody: data];
NSLog(@"the url is %@",url);
NSLog(@"data is %@",data);
conn= [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( conn )
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
[post release];
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"did recieve response: %@", response);
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSMutableString *schoolStr = [[NSMutableString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog(@"loginStatus %@",schoolStr);
recievedSchool= [NSMutableArray arrayWithArray:[schoolStr componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@"$"]]];
// [self getTeacher:schoolStr];
// [newschool addobject :schoolStr];
[recievedSchool addObject:schoolStr];
NSLog(@"array value is %@",recievedSchool);
[self.tableView reloadData];
[schoolStr release];
[connection release];
[webData release];
}
有人能帮我吗?试试看
[recievedSchool retain];
在上面
[self.tableView重载数据]
在ConnectiondFinishLoading method中,有人能帮我吗;m making error当您试图访问CellForRowatinedExath中的ReceivedSchool数组时,是否出现exec错误访问错误?在何处使用此[ReceivedSchool retain];关于didfinish或其他地方,还有一个问题是我是否应该释放此保留?您可以使用dealloc方法安全释放它