Solution to memory leak problem
A memory leak (Memory leaks) is when an object or variable is not released after use, and the object holds the memory until the application stops. If this object is too much memory will be exhausted, other applications will not run. This problem is more common in the MRR of C + +, C and objective-c.
The memory that frees objects in Objective-c is to send release and autorelease messages, both of which can subtract the reference count by 1, and when the reference count is 0, releasing message causes the object to be released immediately. The autorelease message causes the object to be put into a memory-free pool for deferred release.
Code on:
-(void) viewdidload {[Super viewdidload];
NSBundle *bundle = [NSBundle mainbundle];
NSString *plistpath = [Bundle pathforresource:@ "Team" oftype:@ "plist"];
Gets all the data in the attribute list file Self.listteams = [[Nsarray alloc] initwithcontentsoffile:plistpath];
}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) IndexPath {
static NSString *cellidentifier = @ "Cellidentifier";
UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:cellidentifier]; if (cell = = nil) {cell = [[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:cellid
Entifier];
Nsuinteger row = [Indexpath row];
Nsdictionary *rowdict = [Self.listteams objectatindex:row];
Cell.textLabel.text = [rowdict objectforkey:@ "name"];
NSString *imagepath = [rowdict objectforkey:@ "image"]; ImagePath = [ImagePath Stringbyappendingstring:@ ". png"];
Cell.imageView.image = [UIImage Imagenamed:imagepath];
Cell.accessorytype = Uitableviewcellaccessorydisclosureindicator;
return cell; }-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath {Nsuin
Teger row = [Indexpath row];
Nsdictionary *rowdict = [Self.listteams objectatindex:row];
NSString *rowvalue = [rowdict objectforkey:@ "name"]; NSString *message = [[NSString alloc] initwithformat:@ "You chose the%@ team.
", Rowvalue]; Uialertview *alert = [[Uialertview alloc]initwithtitle:@ "Please select Team" Message:message delegate:self
uttontitle:@ "OK" otherbuttontitles:nil];
[Alert show];
[TableView Deselectrowatindexpath:indexpath Animated:yes]; }