Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-28-2011, 05:54 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2011
Location: Southern California
Posts: 20
Shayizzle710 is on a distinguished road
Default Showing contents of all NSMutableArrays for all NSMutableArrays?

Hey everyone. I'm still getting the hang of Objective-C and I've been having trouble where my tableview is not showing data that is unique to the array that is created by an object of a main array.

I'm probably thinking it could be this line that is causing all data from all arrays of other objects to show up in the tableview:

Code:
//CardsViewController.m

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
	StudyCardsLiteAppDelegate *appDelegate = (StudyCardsLiteAppDelegate*)[[UIApplication sharedApplication] delegate];
    return [[[appDelegate.deckArray objectAtIndex:appDelegate.deckLevel] deckList] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
	StudyCardsLiteAppDelegate *appDelegate = (StudyCardsLiteAppDelegate*)[[UIApplication sharedApplication] delegate];
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
    
    // Configure the cell...
	cell.textLabel.text = [[[[appDelegate.deckArray objectAtIndex:appDelegate.deckLevel] deckList] objectAtIndex:indexPath.row] cardTitle];
	cell.detailTextLabel.text = [[[[appDelegate.deckArray objectAtIndex:appDelegate.deckLevel] deckList] objectAtIndex:indexPath.row] cardBody];

	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
	
    
    return cell;
}
or somewhere in here:

Code:
//CreateCardViewController.m

-(IBAction) makeCard:(id)sender {
	
	NSLog(@"adding new card");
	StudyCardsLiteAppDelegate *appDelegate = (StudyCardsLiteAppDelegate*)[[UIApplication sharedApplication] delegate];
	Cards *newCard = [[Cards alloc] init];
	
	[newCard setCardTitle:cardTitleText.text];	NSLog(@"%@", newCard.cardTitle);
	[newCard setCardBody:cardBodyText.text];	NSLog(@"%@", newCard.cardBody);		
	[[[appDelegate.deckArray objectAtIndex:appDelegate.deckLevel] deckList] insertObject:newCard atIndex:[[[appDelegate.deckArray objectAtIndex:appDelegate.deckLevel] deckList] count]];
	[newCard release];
	
	[cvController.newTableView reloadData];
	cardTitleText.text = @"";
	cardBodyText.text = @"";
	createButton.enabled = NO;

	[self dismissModalViewControllerAnimated:YES];

}
where deckArray is the main NSMutableArray that is declared in the AppDelegate and deckLevel is an NSInteger in the AppDelegate that is set to indexPath.row in the previous viewcontroller where I make the deck object (contains deck title as a string and deckList as an NSMutableArray). I am pretty sure the data is being saved to their respective arrays, because when I try to delete a row in the tableview that belongs to another deck, the App crashes in the simulator, meaning it does not exist in that array as well.

I have been trying to figure out what is wrong for hours and still can't find what is causing this. What could the problem be?
Shayizzle710 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 406
7 members and 399 guests
JackReidy, jeroenkeij, Leslie80, Sami Gh, Wikiboo, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:46 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0