Hi all,
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
{
NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier]autorelease];
}
//UITableViewCell *cell = [[UITableViewCell alloc]init];
itemObject = nil;
itemObject = [menuObject.menuItemsArray objectAtIndex:indexPath.row];
cell.text = itemObject.itemName;
cell.font = [UIFont systemFontOfSize:13.0];
cell.textColor = [UIColor blackColor];
cell.textAlignment = UITextAlignmentLeft;
if(itemObject.iImg != nil)
{
if([[itemObject.iImg substringToIndex:4] isEqualToString"http"])
{
//NSAutoreleasePool *poolObj = [[NSAutoreleasePool alloc]init];
NSURL *urlString = [[NSURL alloc]initWithString:itemObject.iImg];
NSData *data = [[NSData alloc]initWithContentsOfURL:urlString];
UIImage *img = [[UIImage alloc]initWithData:data];
cell.image = img; //[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:itemObject.iImg]]];
img = nil;
data = nil;
urlString = nil;
itemObject = nil;
//[poolObj drain];
}
else
{
cell.image = [UIImage imageNamed:itemObject.iImg];
}
state = 1;
}
//[itemObject release];
return cell;
}
when i run my app,i see leaks in my instruments and when we trace the stack it will go to this line.
NSData *data = [[NSData alloc]initWithContentsOfURL:urlString];
i am not able to find it out why.so please help me.
Not only here,i am parsong xml files using NSXMLParser object,it will show me leaks at this line also
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
i am relesing parser object.
- (void)parseXMLFileAtURLNSURL *)URL parseErrorNSError **)error
{
//[self parseXMLFileAtData:[NSData dataWithContentsOfURL:URL options:1 error:error]];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
// Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks.
[parser setDelegate:self];
// Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser.
[parser setShouldProcessNamespaces:NO];
[parser setShouldReportNamespacePrefixes:NO];
[parser setShouldResolveExternalEntities:NO];
[parser parse];
NSError *parseError = [parser parserError];
if (parseError && error)
{
*error = parseError;
}
[parser release];
}
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
{
NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier]autorelease];
}
//UITableViewCell *cell = [[UITableViewCell alloc]init];
itemObject = nil;
itemObject = [menuObject.menuItemsArray objectAtIndex:indexPath.row];
cell.text = itemObject.itemName;
cell.font = [UIFont systemFontOfSize:13.0];
cell.textColor = [UIColor blackColor];
cell.textAlignment = UITextAlignmentLeft;
if(itemObject.iImg != nil)
{
if([[itemObject.iImg substringToIndex:4] isEqualToString"http"])
{
//NSAutoreleasePool *poolObj = [[NSAutoreleasePool alloc]init];
NSURL *urlString = [[NSURL alloc]initWithString:itemObject.iImg];
NSData *data = [[NSData alloc]initWithContentsOfURL:urlString];
UIImage *img = [[UIImage alloc]initWithData:data];
cell.image = img; //[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:itemObject.iImg]]];
img = nil;
data = nil;
urlString = nil;
itemObject = nil;
//[poolObj drain];
}
else
{
cell.image = [UIImage imageNamed:itemObject.iImg];
}
state = 1;
}
//[itemObject release];
return cell;
}
when i run my app,i see leaks in my instruments and when we trace the stack it will go to this line.
NSData *data = [[NSData alloc]initWithContentsOfURL:urlString];
i am not able to find it out why.so please help me.
Not only here,i am parsong xml files using NSXMLParser object,it will show me leaks at this line also
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
i am relesing parser object.
- (void)parseXMLFileAtURLNSURL *)URL parseErrorNSError **)error
{
//[self parseXMLFileAtData:[NSData dataWithContentsOfURL:URL options:1 error:error]];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
// Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks.
[parser setDelegate:self];
// Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser.
[parser setShouldProcessNamespaces:NO];
[parser setShouldReportNamespacePrefixes:NO];
[parser setShouldResolveExternalEntities:NO];
[parser parse];
NSError *parseError = [parser parserError];
if (parseError && error)
{
*error = parseError;
}
[parser release];
}