Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Jan 13, 2011, 03:52 PM   #1
macrumors newbie
Join Date: Jan 2011
Location: Regina,Sask
About loading plist into navigator


I'm beginner of X-code, now i'm trying to load the data from plist file into navigator but it didn't work well. When application is run, I can see my data from plist but it's not too long because the app. will close itself (I could not slide up and down to fast too ). I don't know why and I tried to release the array but it didn't work, I couldn't access to see the data. If somebody knows how to solve this o, please tell me. Many thanks

Here is my code

NSString *path = [[NSBundle mainBundle]pathForResource:@"statedictionary1" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc]initWithContentsOfFileath];
self.keys = dict;
[dict release];

NSArray *array = [[keys allKeys]sortedArrayUsingSelector:@selector(compare];
self.list = array;

I couldn't release the array because my app will get crashed. I don't know why
MynEz is offline   0 Reply With Quote
Old Jan 13, 2011, 04:20 PM   #2
robbieduncan's Avatar
Join Date: Jul 2002
Location: London
You are releasing an object you don't own. Read the (and understand) the Memory Management Guide.
robbieduncan is offline   0 Reply With Quote
Old Jan 13, 2011, 04:25 PM   #3
balamw's Avatar
Join Date: Aug 2005
Location: New England
Please read the sticky thread about the use of the CODE tags. http://forums.macrumors.com/showthread.php?t=747660. Your code is now mangled.

MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Jan 13, 2011, 10:16 PM   #4
Thread Starter
macrumors newbie
Join Date: Jan 2011
Location: Regina,Sask
Thank you for your reply

@robbieduncan : I didn't get it yet, but I 've fixed my code now. I can release the array and it works though. There's still one problem, when I scroll up or down quickly or sometimes just scrolling down or up, the application still closed itself. Did I do something wrong? or could you tell me how to fix the code?

	NSString *path = [[NSBundle mainBundle]pathForResource:@"statedictionary1" ofType:@"plist"];
	NSDictionary *dict = [[NSDictionary alloc]initWithContentsOfFile:path];
	self.keys = dict;
	[dict release];
	NSArray *array = [[NSArray alloc] init];
	[array release];				  
	array = [[keys allKeys]sortedArrayUsingSelector:@selector(compare:)];
	self.list = array;
	[super viewDidLoad];

	self.list = nil;
	[super viewDidUnload];

	self.list =nil;
	[super didReceiveMemoryWarning];

	[super dealloc];
	[list release];
	[keys release];
	[childController release];


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	return [self.list count];

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

	NSString *button = @"Sunday";
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:button];
	if(cell == nil){
		cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:button]autorelease];
	NSUInteger row = [indexPath row];
	NSString *rowString =[list objectAtIndex:row];
	cell.textLabel.text = rowString;
	cell.textLabel.font = [UIFont systemFontOfSize:15];
	cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
	[rowString release];
	return cell;


-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
	if (childController == nil)
		childController = [[DetailSecond alloc]initWithNibName:@"DetailSecond" bundle:nil ];
	childController.title = @"SundayZ";
	NSUInteger row = [indexPath row];
	NSString *selectedR =[list objectAtIndex:row];
	NSString *details = [[NSString alloc]initWithFormat:@"You press %@", selectedR];
	childController.message = details;
	childController.title = selectedR;
	[details release];
	[self.navigationController pushViewController:childController animated:YES];
@balamw I'm sorry, I apologize, I've just registered half a day. - -"
MynEz is offline   0 Reply With Quote
Old Jan 14, 2011, 12:57 AM   #5
dejo's Avatar
Join Date: Sep 2004
Location: The Centennial State
You can't release rowString either. Have you read the Memory Management Guide yet?

P.S. There's also a problem with the order of things in your dealloc.
My iOS Apps: a.k.a., DreamStream, Flag Holidays
I support the MacRumors Blood Drive!

Last edited by dejo; Jan 14, 2011 at 08:41 AM. Reason: Added P.S.
dejo is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
App Store loading...loading...loading evilrt iPhone Tips, Help and Troubleshooting 0 Sep 22, 2013 08:05 AM
Maps as offline navigator... sev7en OS X Mavericks (10.9) 7 Jun 17, 2013 12:11 PM
Launchctl hangs on loading plist ttown1079 OS X 10.8 Mountain Lion 0 Jun 4, 2013 09:54 PM
Websites not fully loading, taking 20-30 seconds to full load - not loading at all? johnnnw MacBook Pro 9 May 29, 2013 10:36 AM
Loading plist into array and randomly grabbing item filename acctman iPhone/iPad Programming 8 Apr 19, 2013 08:37 AM

Forum Jump

All times are GMT -5. The time now is 01:51 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC